- Learn Qt 5
- Nicholas Sherriff (Nick)
- 641字
- 2021-06-30 18:42:31
Project creation
In the previous chapter, we saw how easy it is to set up a new project just by creating a few text files. However, we’ll create our new solution using Qt Creator. We will use the new project wizard to guide us through creating a top-level solution and a single subproject.
From the top menu, select File > New File or Project and then Projects > Other Project > Subdirs Project and click on Choose…:

Subdirs Project is the template we need for our top-level solution project. Give it the name cm and create it in our qt projects folder:

On the Kit Selection pane, check the Desktop Qt 5.10.0 MinGW 32bit kit we installed. Feel free to select additional kits you want to try out if you have them installed, but it’s not necessary. Click on Next:

As discussed, version control is beyond the scope of this book, so in the Project Management pane, select None from the Add to version control dropdown. Click on Finish & Add Subproject:

We’ll add the user interface project as the first subproject. The wizard follows more or less the same pattern as the steps we've just followed, so perform the following:
- Select Projects > Application > Qt Quick Application - Empty and click on Choose...
- In the Project Location dialog, give it the name cm-ui (for Client Management - User Interface), leave the location as our new cm folder, and click on Next.
- In the Define Build System dialog, select the build system qmake and click on Next.
- In the Define Project Details dialog, leave the default minimal Qt version of QT 5.9 and the Use Qt Virtual Keyboard box unchecked then click on Next.
- In the Kit Selection dialog, pick the Desktop Qt 5.10.0 MinGW 32bit kit plus any other kits you wish to try and click on Next.
- Finally, in the Project Management dialog, skip version control (leave it as <None>) and click on Finish.
Our top-level solution and UI projects are now up and running, so let’s add the other subprojects. Add the business logic project next, as follows:
- In the Projects pane, right-click on the top-level cm folder and select New Subproject….
- Select Projects > Library > C++ Library and click on Choose....
- In the Introduction and Project Location dialog, pick Shared Library as the Type, name it cm-lib, create it in <Qt Projects>/cm, and then click on Next.
- In the Select Required Modules dialog, just accept the default of QtCore and click on Next.
- In the Class Information dialog, we get the opportunity to create a new class to get us started. Give the class name Client, with the client.h header file and the client.cpp source file, and then click on Next.
- Finally, in the Project Management dialog, skip version control (leave it as <None>) and click on Finish.
Finally, we will repeat the process to create our unit testing project:
- New Subproject....
- Projects > Other Project > Qt Unit Test.
- Project name cm-tests.
- Include QtCore and QtTest.
- Create the ClientTests test class with the testCase1 test slot and the client-tests.cpp filename. Set the Type as Test and check Generate initialization and cleanup code.
- Skip version control and Finish.
That was a lot of dialog boxes to get through, but we’ve now got our skeleton solution in place. Your project folders should look as follows:

We’ll now take a look at each project in turn and make some tweaks before we start adding our content.
- Learning SQL Server Reporting Services 2012
- 龍芯應用開發標準教程
- Python GUI Programming:A Complete Reference Guide
- Mastering Delphi Programming:A Complete Reference Guide
- Mastering Manga Studio 5
- 分布式微服務架構:原理與實戰
- Machine Learning Solutions
- 計算機組裝維修與外設配置(高等職業院校教改示范教材·計算機系列)
- 單片機系統設計與開發教程
- 單片機開發與典型工程項目實例詳解
- RISC-V處理器與片上系統設計:基于FPGA與云平臺的實驗教程
- Java Deep Learning Cookbook
- Spring Cloud實戰
- IP網絡視頻傳輸:技術、標準和應用
- FPGA實戰訓練精粹