Deploy Qt5 QML application

前端 未结 5 1604
广开言路
广开言路 2020-12-03 11:49

To test QML deployment I\'ve created a very simple QML application. Here is the code:

main.cpp

#include 

        
5条回答
  •  佛祖请我去吃肉
    2020-12-03 12:27

    This what i've figured out so far,

    You can't just open a qml file in main.cpp, you have to put those qmls into a resource

    qml.qrc:

    
        
            main.qml
        
    
    

    Then main.cpp must load it from the resource

    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        return app.exec();
    }
    

    then build and check it works, then deploy as follows:

    • locate the releasse directory where your EXE lives
    • locate the directory where your QML lives
    • create a directory somewhere, say, deploy

    then

    cd deploy
    windeployqt --release --qmldir  
    

    NOTE: add location of windeployqt to PATH eg. C:\Qt\Qt5.5.1\5.5\msvc2013\bin

提交回复
热议问题