官术网_书友最值得收藏!

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!

主站蜘蛛池模板: 武邑县| 青海省| 丘北县| 邹城市| 盘锦市| 江津市| 荔浦县| 抚宁县| 昌江| 禄丰县| 甘谷县| 根河市| 三亚市| 托克逊县| 祁连县| 哈密市| 惠州市| 罗江县| 桃园市| 颍上县| 永丰县| 会宁县| 阿克| 东兰县| 泗水县| 晴隆县| 青阳县| 合肥市| 永嘉县| 南陵县| 武清区| 琼结县| 洞头县| 新邵县| 青海省| 泉州市| 吉隆县| 顺义区| 乌拉特后旗| 阆中市| 鄂伦春自治旗|