部署Qt5 QML应用程序 [英] Deploy Qt5 QML application

查看:298
本文介绍了部署Qt5 QML应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了测试QML部署,我创建了一个非常简单的QML应用程序。这是代码:



main.cpp

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

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

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

main.qml



< pre class =lang-js prettyprint-override> import QtQuick 2.2
import QtQuick.Controls 1.2

ApplicationWindow {
id:mainWindow
标题:测试窗口
width:800
height:600
visible:true
}

为了确保系统中没有安装开发库,我已经设置了一个纯Windows XP安装的虚拟机。然后,我按照此处所述的说明进行操作,并复制<强>全部 Qt5 * .dll进入程序目录,以及平台/ qwindows.dll和icu * 52.dll。依赖性Walker证实没有遗漏的依赖关系,即一切都应该已经正确设置了。



然而,由于某些原因,当我运行我的应用程序时,我什么也看不见。窗口也不是错误信息。从控制台运行也给我没有错误。尽管如此,我可以看到我的应用程序在任务管理器中运行,就像在后台运行一样。在开发机器上运行应用程序没有问题:应用程序正确启动,我可以看到它的窗口。



我做错了什么?如何部署QML应用程序,以确保它可以在任何其他非开发机器上运行?

解决方案

如果您使用MinGW,然后尝试从您的程序将文件夹 qml 插件中的所有文件夹复制到目录。也复制库: 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 bin



最终目录将如下所示:




  • Enginio

  • imageformats
  • 平台

  • Qt

  • QtGraphicalEffects

  • QtPositioning
  • $ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
  • QtWebKit

  • QtWinExtras

  • icudt52.dll

  • icuin52.dll

  • icuuc52.dll

  • libgcc_s_dw2-1.dll

  • libstdc ++ - 6.dll

  • libwinpthread-1.dll

  • Qt5Core.dll

  • Qt5Gui.dl l

  • Qt5Network.dll

  • Qt5Qml.dll

  • Qt5Quick.dll

  • Qt5Svg.dll

  • Qt5Widgets.dll

  • YOUR_PROGRAM.exe



这种方式适用于没有安装Qt的WindowsXP / Win7。


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?

解决方案

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.

这篇关于部署Qt5 QML应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆