Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
828 views
in Technique[技术] by (71.8m points)

qt - Deploy Qt5 QML application

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

main.cpp

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QFile>

int main(int argc, char **argv) {
    QApplication app(argc, argv);
    QQmlApplicationEngine engine;

    QString path = app.applicationDirPath() + "/qml/main.qml";
    if(QFile::exists(path))
        engine.load(path);
    else {
        return 1;
    }
    return app.exec();
}

main.qml

import QtQuick 2.2
import QtQuick.Controls 1.2

ApplicationWindow {
    id: mainWindow
    title: "Test window"
    width: 800
    height: 600
    visible: true
}

To be sure no development library was installed in the system, I've set up a virtual machine with a pure Windows XP installation. Then, I've followed instructions as described here and copied all Qt5*.dll into the program directory, as well as platforms/qwindows.dll and icu*52.dll. Dependency Walker confirmed that no broken dependencies were left, i.e. everything should have been correctly set up.

However, for some reasons, when I run my app I see nothing. Neither a window, nor an error message. Running from console also gives me no error. Despite this, I can see my app running in the Task manager, like it is running in background. Running the app on the development machine goes without problem: the app correctly starts and I can see its windows.

What am I doing wrong? How can I deploy a QML app to be sure it will work on any other - non development - machine?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you use MinGW, then try to copy all folders from folders qml and plugins to directory with your program. Also copy libraries: icudt52.dll, icuin52.dll, icuuc52.dll, libgcc_s_dw2-1.dll, libstdc++-6.dll, libwinpthread-1.dll, Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5Qml.dll, Qt5Quick.dll, Qt5Svg.dll, Qt5Widgets.dll from bin

Eventually the directory will look like this:

  • Enginio
  • imageformats
  • platforms
  • Qt
  • QtGraphicalEffects
  • QtPositioning
  • QtQml
  • QtQuick
  • QtQuick.2
  • QtSensors
  • QtWebKit
  • QtWinExtras
  • icudt52.dll
  • icuin52.dll
  • icuuc52.dll
  • libgcc_s_dw2-1.dll
  • libstdc++-6.dll
  • libwinpthread-1.dll
  • Qt5Core.dll
  • Qt5Gui.dll
  • Qt5Network.dll
  • Qt5Qml.dll
  • Qt5Quick.dll
  • Qt5Svg.dll
  • Qt5Widgets.dll
  • YOUR_PROGRAM.exe

This way works on WindowsXP/Win7 where Qt was not installed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...