- 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.
- WebAssembly實戰
- Django開發從入門到實踐
- 琢石成器:Windows環境下32位匯編語言程序設計
- C語言程序設計教程
- Mastering Xamarin.Forms(Second Edition)
- Test-Driven Development with Django
- Mobile Device Exploitation Cookbook
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- 精通MySQL 8(視頻教學版)
- 網絡數據采集技術:Java網絡爬蟲實戰
- Python一行流:像專家一樣寫代碼
- Visual Basic程序設計實驗指導及考試指南
- PHP項目開發全程實錄(第4版)
- Mastering ASP.NET Core 2.0
- 樹莓派開發從零開始學:超好玩的智能小硬件制作書