I can't run static qt-qml app on another computer



  • I built qt statically with params:
    @
    C:\Qt5.3\5.3\StaticQt>configure -prefix c:\Qt5.3\5.3\StaticQt\qtbase -opensource -static -release -opengl desktop -nomake examples -nomake tests -confirm-license
    @
    Added this built in Qt Versions (with warning: non-installed -prefix build - for internal development only), make corresponding Kit. App size = 24Mb. I can run app on my own computer with Windows 7 not from QtCreator. But from another desktop with Win7 and WinXP i can't run it. The program is really runs (in Task Manager) but i do not see interface. Help me please!
    .pro file:
    @
    TEMPLATE = app

    QT += qml quick widgets

    SOURCES += main.cpp

    RESOURCES += qml.qrc

    Additional import path used to resolve QML modules in Qt Creator's code model

    QML_IMPORT_PATH =

    Default rules for deployment.

    include(deployment.pri)
    @
    .cpp
    @
    #include <QApplication>
    #include <QQmlApplicationEngine>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
    
    return app.exec&#40;&#41;;
    

    }
    @
    .qml
    @
    import QtQuick 2.2
    import QtQuick.Controls 1.1

    ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }
    
    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
    

    }
    @

    This is a standard template for QtQuick projects.
    P.S. i am a newbie in qt and i need your help!



  • Have you tried running your application from the command line? Maybe it outputs some debug information.



  • The problem is in plugins. I changed my source code to:
    @
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>

    #include <QQuickView>
    #include <QtPlugin>
    #include <QQmlEngine>

    #include <QQmlExtensionPlugin>
    Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
    Q_IMPORT_PLUGIN(QtQuick2Plugin)

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2Plugin().instance())->registerTypes("QtQuick");
    
    /*QQmlApplicationEngine engine;
    //engine.setImportPathList(QStringList());
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));*/
    
    QQuickView viewer;
    viewer.engine()->setImportPathList(QStringList());
    viewer.setSource(QUrl(QStringLiteral("qrc:///main.qml")));
    viewer.show();
    
    return app.exec&#40;&#41;;
    

    }
    @
    And qml to:
    @
    import QtQuick 2.2
    //import QtQuick.Controls 1.1

    Rectangle{
    width: 200
    height: 200
    color: "LightGreen"
    }

    /*ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit2")
                onTriggered: Qt.quit();
            }
        }
    }
    
    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
    

    }*/
    @
    And it works. But when i tryed to include QtQuick.Controls 1.1 and use ApplicationWindow in qml and QQmlApplicationEngine in cpp, it NOT did work!
    With:
    @
    QQmlApplicationEngine failed to load component
    qrc:///main.qml:10 Type ApplicationWindow unavailable
    qrc:/QtQuick/Controls/ApplicationWindow.qml:41 module "QtQuick.Window" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:44 module "QtQuick.Layouts" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:45 module "QtQuick.Controls.Private" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:41 module "QtQuick.Window" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:44 module "QtQuick.Layouts" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:45 module "QtQuick.Controls.Private" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:41 module "QtQuick.Window" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:44 module "QtQuick.Layouts" is not installed
    qrc:/QtQuick/Controls/ApplicationWindow.qml:45 module "QtQuick.Controls.Private" is not installed
    @



  • Today i made some progress: i included plugins with help of code:
    @
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>

    #include <QQuickView>
    #include <QtPlugin>
    #include <QQmlEngine>
    #include <QDebug>

    #define STATIC_BUILD

    #ifdef STATIC_BUILD
    #include <QQmlExtensionPlugin>
    Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
    Q_IMPORT_PLUGIN(QtQuick2Plugin)
    Q_IMPORT_PLUGIN(QtQuickControlsPlugin)
    Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
    Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)
    #endif

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    #ifdef STATIC_BUILD
        qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2Plugin().instance())->registerTypes("QtQuick 2.2");
        qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls");
        qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls.Private");
        qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls.Styles");
        qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickLayoutsPlugin().instance())->registerTypes("QtQuick.Layouts");
        qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2WindowPlugin().instance())->registerTypes("QtQuick.Window");
    #endif
    
    QQmlApplicationEngine engine;
    #ifdef STATIC_BUILD
        engine.setImportPathList(QStringList());
    #endif
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
    QStringList list = engine.importPathList();
    qDebug() << "ImportPathList" << list;
    
    /*QQuickView viewer;
    viewer.engine()->setImportPathList(QStringList());
    viewer.setSource(QUrl(QStringLiteral("qrc:///main.qml")));
    viewer.show();*/
    
    return app.exec();
    

    }
    @
    Now the error is:
    qrc:/QtQuick/Controls/ApplicationWindow.qml:201 ContentItem is not a type

    I think strings:
    @
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls.Private");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls.Styles");
    @
    is not valid, because ContentItem declared in QtQuick.Controls.Private. People help!





  • I have the same problem. Did you find any solution ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.