Skip to content

Commit 3af9489

Browse files
committed
updates to example.md
1 parent df04a2e commit 3af9489

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

EXAMPLES.md

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,27 @@ Different types of examples are provided. All examples have a frontend implement
1111
| BasicC++ | IV | QML | Mock QML | need to be compiled |
1212

1313

14-
## How to run
14+
## Python environment and IDE
1515

16-
### Type I Examples: BasicQml (QML runtime with QML backend)
16+
### Python environment
17+
* Install the Qt `PySide6` module in the desired python environment
18+
***macOS and Linux***
19+
20+
```sh
21+
$ python3.11 -m venv .venv # create new python environment '.venv'
22+
$ source .venv/bin/activate # activate '.venv'
23+
$ pip install PySide6 # install Qt for Python
24+
```
1725

18-
This example consists of a graphical QML frontend and a "mock" QML backend. By a mock backend is meant that it only returns hardcoded values rather than providing the required functionality. The resulting application will be displayed using Qt `qml` viewer.
26+
***Windows***
1927

20-
#### Preparation
28+
```sh
29+
$ python3.11 -m venv .venv # create new python environment '.venv'
30+
$ .venv\Scripts\activate # activate '.venv'
31+
$ pip install PySide6 # install Qt for Python
32+
```
2133

34+
### QT Creator
2235
* Download Qt Online Installer from [qt.io](https://www.qt.io/download-qt-installer-oss). More info at [doc.qt.io](https://doc.qt.io/qt-6/qt-online-installation.html).
2336
* Install Qt for desktop development using a custom installation that includes the following components:
2437
* Qt
@@ -31,9 +44,22 @@ This example consists of a graphical QML frontend and a "mock" QML backend. By a
3144
* [ ] Developer and Designer Tools
3245
* [x] Qt Creator x.y.z
3346

47+
### VSCode
48+
* Download an install VSCode
49+
* Add the python extension
50+
* Rename the folder `vscode` to `.vscode`. The `launch.json` file will then be read by VSCode
51+
* Select any python file in the repo and choose the desired python environment
52+
53+
54+
## How to run
55+
56+
### Type I Examples: BasicQml (QML runtime with QML backend)
57+
58+
This example is located in `examples/BasicQml` and the source code is in the subfolder `src/BasicQml`. The example consists of a graphical QML frontend (`Gui/Application.qml`) and a QML backend (`Logic/Mock/BackendProxy.qml`). It is considered a mock backend as it only returns hardcoded values rather than providing the required functionality. The entry point for Qt is `main.qml`, whcih can be displayed using Qt `qml` viewer.
59+
3460
#### Qt Creator IDE (QML Runtime)
3561
* Run Qt Creator
36-
* Open the qml project file `*.qmlproject` from the example folder from `examples/BasicQml/src/BasicQml.qmlproject`
62+
* Open the qml project file `*.qmlproject` from the example folder from `src/BasicQml.qmlproject`
3763
* Click Run (Green play button)
3864

3965
#### Run from the terminal (QML Runtime)
@@ -50,7 +76,6 @@ This example consists of a graphical QML frontend and a "mock" QML backend. By a
5076
```
5177

5278
#### How to edit GUI elements in live mode
53-
5479
* In Qt Creator, select the `.qml` file to be edited in live mode
5580
* Click the `Design` button at the top of the left sidebar of `Qt Creator`
5681
* _Note: If this button is disabled, find and click `About plugins...` in the `Qt Creator` menu, scroll down to the `Qt Quick` section and enable `QmlDesigner`._
@@ -60,41 +85,16 @@ This example consists of a graphical QML frontend and a "mock" QML backend. By a
6085

6186
### Type II Examples: BasicMinimalPy (Python runtime with QML backend)
6287

63-
This example serves to demonstrate how an application with a QML frontend and a QML "mock" backend can be executed from Python.
64-
65-
Most examples can be run via Python, even if they only have a mock backend in QML (the Python backend is not implemented). The minimum configuration requires a base `main.py` file. To execute this one needs to the following:
66-
67-
#### Preparation
68-
69-
* Download and install the Qt Framework following the instruction above for the Type I example
70-
* Install the Qt PySide6 module in the desired python environment
71-
72-
***macOS and Linux***
73-
74-
```sh
75-
$ python3.11 -m venv .venv # create new python environment '.venv'
76-
$ source .venv/bin/activate # activate '.venv'
77-
$ pip install PySide6 # install Qt for Python
78-
```
79-
80-
***Windows***
81-
82-
```sh
83-
$ python3.11 -m venv .venv # create new python environment '.venv'
84-
$ .venv\Scripts\activate # activate '.venv'
85-
$ pip install PySide6 # install Qt for Python
86-
```
88+
This example is located in `examples/BasicMinimalPy` with the source code in `src/BasicMinimalPy`. This example serves to demonstrate how an application with a QML frontend and a QML backend (similar to the Type I example) can be executed from Python. The entry point for the Python program is `main.py` file. To execute this do the following:
8789

8890
#### QtCreator IDE (Python Runtime)
8991
* Run Qt Creator
9092
* Open the python project file `*.pyproject` from the example folder from `examples/BasicMinimalPy/src/BasicMinimalPy.pyproject`
91-
* Select the desired python environment with the Qt PySide6 module installed
93+
* Select the desired python environment with the Qt `PySide6` module installed
9294
* Click Run (Green play button)
9395

9496
#### VSCode IDE (Python Runtime)
9597
* Open the repo in VSCode
96-
* Rename the folder `vscode` to `.vscode`. The `launch.json` file will then be read by VSCode
97-
* Select any python file in the repo and choose the desired python environment
9898
* Click on the debug extension and select which example to execute
9999
![Debug dropdown window](.\resources\images\vscode_debug.jpg)
100100

@@ -112,9 +112,7 @@ Most examples can be run via Python, even if they only have a mock backend in QM
112112

113113
### Type III Examples: BasicPy and IntermediatePy (Python runtime with Py backend)
114114

115-
These examples demonstrate how to use a Python runtime to execute the QML frontend and a Python backend.
116-
117-
These examples can be run through Python in the same way as Type II described above. These examples have a Python-based backend (proxy object), which is created in `main.py` and then get exposed to QML. Communication between the Qt QML frontend and the Python backend occurs through this python proxy.
115+
These examples demonstrate how to use a Python runtime to execute the QML frontend and the Python backend located in `Logic/Py/backend_proxy.py`. These examples can be run through Python in the same way as Type II described above. These examples have a Python-based backend (proxy object), which gets created in `main.py` and then exposed to QML. The Qt QML frontend then acceses the backend by calling methods exposed by the proxy object in the `Py` folder.
118116

119117
#### Possible Issues
120118

0 commit comments

Comments
 (0)