- Learn Qt 5
- Nicholas Sherriff (Nick)
- 259字
- 2021-06-30 18:42:32
cm-ui
Create two subfolders this time: source and views. Move main.cpp into source and main.qml into views. Rename qml.qrc as views.qrc and edit cm-ui.pro:
QT += qml quick
TEMPLATE = app
CONFIG += c++14
INCLUDEPATH += source
SOURCES += source/main.cpp
RESOURCES += views.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = $$PWD
Our UI is written in QML, which requires the qml and quick modules, so we add those. We edit the RESOURCES variable to pick up our renamed resource file and also edit the QML_IMPORT_PATH variable, which we will cover in detail when we get into custom QML modules.
Next, edit views.qrc to account for the fact that we have moved the main.qml file into the views folder. Remember to right-click and Open With > Plain Text Editor:
<RCC> <qresource prefix="/"> <file>views/main.qml</file> </qresource> </RCC>
Finally, we also need to edit a line in main.cpp to account for the file move:
engine.load(QUrl(QStringLiteral("qrc:/views/main.qml")));
You should now be able to run qmake and rebuild the cm-ui project. Before we run it, let’s take a quick look at the build configuration button now that we have multiple projects open:

Note that now, along with the Kit and Build options, we must also select the executable we wish to run. Ensure that cm-ui is selected and then run the application:

Hello World indeed. It's fairly uninspiring stuff, but we have a multiproject solution building and running happily, which is a great start. Close the application when you simply can’t take any more fun!
- 24小時學會電腦組裝與維護
- ATmega16單片機項目驅動教程
- Android NDK Game Development Cookbook
- 極簡Spring Cloud實戰
- 嵌入式系統設計教程
- 深入淺出SSD:固態存儲核心技術、原理與實戰(第2版)
- 筆記本電腦維修不是事兒(第2版)
- Rapid BeagleBoard Prototyping with MATLAB and Simulink
- 筆記本電腦維修300問
- Spring Cloud微服務和分布式系統實踐
- 微服務實戰(Dubbox +Spring Boot+Docker)
- 計算機組成技術教程
- 筆記本電腦的結構、原理與維修
- 從企業級開發到云原生微服務:Spring Boot實戰
- 現代多媒體技術及應用