- Game Programming Using Qt Beginner's Guide
- Witold Wysota Lorenz Haas
- 350字
- 2021-08-20 10:45:18
Time for action – the main window of the application
Create a new Qt Designer Form Class application. As a template, choose Main Window. Accept the default values for the rest of the wizard.
Create an action using the action editor and enter the following values in the dialog:

Now, create another action and fill it with the values shown in the following screenshot:

We want our game to look nice, so we will provide icons for the actions and we will embed images for them in our application using the resource system. Create a new file and make it Qt Resource File. Call it resources.qrc
. Click on the Add button and choose Add Prefix. Change the value for the prefix to /
. Then, click on the Add button again and choose Add Files. Find appropriate images for your actions and add them to the resource file. A dialog will appear asking whether you want to copy the files to the project directory. Agree by choosing Copy.

Now, edit the actions again in the Action Editor and choose icons for them.
What just happened?
We added a resource file to our project. In that resource file, we created entries for a number of images. Each of the images is put under a /
prefix, which stands for the root node of the artificial filesystem that we create. Each entry in a resource file can be accessed directly from the manually written code as a file with a special name. This name is assembled from three components. First comes a colon character (:
), which identifies the resource filesystem. This is followed by a prefix (for example, /
) and a full path of the entry in the resource (for example, exit.png
). This makes an image called exit.png
accessible through the :/exit.png
path. When we build the project, the file will be transformed into a C data array code and integrated with the application binary. Having prepared the resource file, we used images embedded there as icons for our actions.
The next step is to add these actions to a menu and toolbar.
- Instant Apache Stanbol
- Visual Basic程序開發(學習筆記)
- FFmpeg入門詳解:音視頻流媒體播放器原理及應用
- OpenCV 3和Qt5計算機視覺應用開發
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- Python程序設計案例教程
- VMware虛擬化技術
- C/C++數據結構與算法速學速用大辭典
- Machine Learning With Go
- Java程序設計與項目案例教程
- Elasticsearch Essentials
- 深入實踐DDD:以DSL驅動復雜軟件開發
- 軟件工程與UML案例解析(第三版)
- 大學計算機基礎實訓教程
- 會當凌絕頂:Java開發修行實錄