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

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!

主站蜘蛛池模板: 饶阳县| 铜梁县| 巴中市| 青州市| 申扎县| 措勤县| 大港区| 大庆市| 吉安县| 枣强县| 万山特区| 平果县| 德庆县| 河池市| 永丰县| 和林格尔县| 鹤壁市| 鱼台县| 洪泽县| 西盟| 双桥区| 南开区| 灌云县| 金塔县| 肇东市| 美姑县| 阿克陶县| 建宁县| 湘乡市| 柞水县| 奈曼旗| 汶上县| 来宾市| 安岳县| 宁夏| 铁岭县| 揭西县| 礼泉县| 洛南县| 四川省| 嘉定区|