Skip to content

Commit c6c7e97

Browse files
committed
Update EXAMPLES.md
1 parent 3af9489 commit c6c7e97

File tree

1 file changed

+67
-39
lines changed

1 file changed

+67
-39
lines changed

EXAMPLES.md

+67-39
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,42 @@ 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-
## Python environment and IDE
14+
## Setting up Python and IDE
1515

1616
### Python environment
17-
* Install the Qt `PySide6` module in the desired python environment
18-
***macOS and Linux***
1917

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
18+
* Create and activate a python environment (_optional_)
19+
20+
***macOS and Linux***
21+
22+
```
23+
python3.11 -m venv .venv
24+
source .venv/bin/activate
2425
```
2526

26-
***Windows***
27+
***Windows***
2728

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
3229
```
30+
python3.11 -m venv .venv
31+
.venv\Scripts\activate
32+
```
33+
34+
* Upgrade the PIP - package installer for Python (_optional_)
35+
36+
```
37+
pip install --upgrade pip
38+
```
39+
40+
* Install the Qt for Python `PySide6` package via PIP
41+
42+
```
43+
pip install PySide6
44+
```
45+
46+
### Integrated development environment (IDE)
47+
48+
#### Qt Creator
3349

34-
### QT Creator
3550
* 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).
3651
* Install Qt for desktop development using a custom installation that includes the following components:
3752
* Qt
@@ -44,39 +59,45 @@ Different types of examples are provided. All examples have a frontend implement
4459
* [ ] Developer and Designer Tools
4560
* [x] Qt Creator x.y.z
4661

47-
### VSCode
48-
* Download an install VSCode
62+
#### VS Code (_alternative to Qt Creator_)
63+
64+
* Download an install VS Code
4965
* Add the python extension
50-
* Rename the folder `vscode` to `.vscode`. The `launch.json` file will then be read by VSCode
66+
* Rename the folder `vscode` to `.vscode`. The `launch.json` file will then be read by VS Code
5167
* Select any python file in the repo and choose the desired python environment
5268

5369

5470
## How to run
5571

5672
### Type I Examples: BasicQml (QML runtime with QML backend)
5773

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.
74+
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`, which can be displayed using Qt `qml` viewer.
5975

60-
#### Qt Creator IDE (QML Runtime)
61-
* Run Qt Creator
62-
* Open the qml project file `*.qmlproject` from the example folder from `src/BasicQml.qmlproject`
63-
* Click Run (Green play button)
76+
#### Run using the QML Runtime
77+
78+
##### Run from the terminal
6479

65-
#### Run from the terminal (QML Runtime)
6680
* Go to the example folder, e.g.,
6781

6882
```sh
69-
$ cd examples/BasicQml/src/BasicQml
83+
cd examples/BasicQml/src/BasicQml
7084
```
7185

7286
* Run `main.qml` (specifying the paths to the current directory `.` and the EasyApp module directory `../../../..`) using the `qml` tool installed with the Qt Framework in the previous step, e.g., like this
7387

7488
```sh
75-
$ ~/Qt/6.x.y/macos/bin/qml -I . -I ../../../.. main.qml
89+
~/Qt/6.x.y/macos/bin/qml -I . -I ../../../.. main.qml
7690
```
7791

92+
##### Run via the Qt Creator IDE (_alternative to run from the terminal_)
93+
94+
* Run Qt Creator
95+
* Open the qml project file from the example folder `examples/BasicQml/src/BasicQml.qmlproject`
96+
* Click Run (Green play button)
97+
7898
#### How to edit GUI elements in live mode
79-
* In Qt Creator, select the `.qml` file to be edited in live mode
99+
100+
* In Qt Creator, select the `*.qml` file to be edited in live mode
80101
* Click the `Design` button at the top of the left sidebar of `Qt Creator`
81102
* _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`._
82103
* In the `Design` window, click the `Show Live Preview` button in the top panel of the application (small play button in a circle).
@@ -87,30 +108,35 @@ This example is located in `examples/BasicQml` and the source code is in the sub
87108

88109
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:
89110

90-
#### QtCreator IDE (Python Runtime)
91-
* Run Qt Creator
92-
* Open the python project file `*.pyproject` from the example folder from `examples/BasicMinimalPy/src/BasicMinimalPy.pyproject`
93-
* Select the desired python environment with the Qt `PySide6` module installed
94-
* Click Run (Green play button)
111+
#### Run using the Python interpreter
95112

96-
#### VSCode IDE (Python Runtime)
97-
* Open the repo in VSCode
98-
* Click on the debug extension and select which example to execute
99-
![Debug dropdown window](.\resources\images\vscode_debug.jpg)
113+
##### Run from the terminal
100114

101-
#### Run from the terminal (Python Runtime)
102115
* Go to the example folder, e.g.,
103116

104117
```sh
105118
$ cd examples/BasicMinimalPy/src/BasicMinimalPy
106119
```
107-
* Run using Python (provided that the required python environment is activated)
120+
* Run using Python (provided that the required python environment is activated as explained above)
108121

109122
```sh
110-
$ python3 main.py
123+
$ python main.py
111124
```
112125

113-
### Type III Examples: BasicPy and IntermediatePy (Python runtime with Py backend)
126+
#### Run via the Qt Creator IDE (_alternative to run from the terminal_)
127+
128+
* Run Qt Creator
129+
* Open the python project file from the example folder `examples/BasicMinimalPy/src/BasicMinimalPy.pyproject`
130+
* Select the desired python environment with the Qt `PySide6` module installed
131+
* Click Run (Green play button)
132+
133+
#### Run via the VS Code IDE (_alternative to run from the terminal or via the Qt Creator IDE_)
134+
135+
* Open the repo in VS Code
136+
* Click on the debug extension and select which example to execute
137+
![Debug dropdown window](resources/images/vscode_debug.jpg)
138+
139+
### Type III Examples: BasicPy and IntermediatePy (Python runtime with Python backend)
114140

115141
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.
116142

@@ -120,4 +146,6 @@ These examples demonstrate how to use a Python runtime to execute the QML fronte
120146

121147
### Type IV Examples: BasicC++
122148

123-
These examples can be run after compilation into an executable program. They only have a mock backend in QML (the C++ backend is not implemented). The minimum configuration requires a base `main.cpp` file and, if Qt Creator is used as the IDE, a `*.pro` file.
149+
This example can be run after compilation into an executable program. It only has a mock backend in QML (the C++ backend is not implemented). The minimum configuration requires a base `main.cpp` file and, if Qt Creator is used as the IDE, a `*.pro` file.
150+
151+
This example is currently used to create a WebAssembly application that can be run inside a web browser.

0 commit comments

Comments
 (0)