Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to surpress QML plugins to be built statically?
Forum Updated to NodeBB v4.3 + New Features

How to surpress QML plugins to be built statically?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jiangcaiyang
    wrote on last edited by
    #1

    I've built Qt 5.3.1 statically, and make a Quick Application based on Quick Application Template generated by Qt Creator.
    When I want to run it standalone, it doesn't show anything though application runs in background. Turning on console and it shows:

    @QQmlApplicationEngine failed to load component
    qrc:///qml/main.qml:2 module "QtQuick.Controls" is not installed
    qrc:///qml/main.qml:1 module "QtQuick" is not installed
    qrc:///qml/main.qml:2 module "QtQuick.Controls" is not installed
    qrc:///qml/main.qml:1 module "QtQuick" is not installed@

    Then after discovery, I know that to resolve this problem, I have to put application binary into $$QTSDK/qml directory.

    My question is how to supress all QML plugins to be built statically so as to remove the dependency of "qml" directory and the application binary is fully "standalone"? all other QML files made myself have been packed into qrc file and compiled via rcc, that is not the problem.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jiangcaiyang
      wrote on last edited by
      #2

      Currently my problem is somewhat the same as the following bug report:
      https://bugreports.qt-project.org/browse/QTBUG-39462
      Now, I have to work around it by explicitly setting code for it.

      @#include <QGuiApplication>
      #include <QQmlApplicationEngine>
      #include <QtPlugin>
      #include <QtQml>

      #if defined(QT_STATIC) && !defined(Q_OS_MAC) && !defined(QT_NAMESPACE)
      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 );

      ……

      QQmlApplicationEngine engine;
      
      // 在静态编译下一个通融的解决方法是显式地注册QML类
      

      #if defined(QT_STATIC) && !defined(Q_OS_MAC) && !defined(QT_NAMESPACE)
      qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2Plugin().instance()) ->registerTypes("QtQuick");
      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.2");

      qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2Plugin().instance())       ->initializeEngine( &engine, "QtQuick");
      qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->initializeEngine( &engine, "QtQuick.Controls");
      qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickLayoutsPlugin().instance()) ->initializeEngine( &engine, "QtQuick.Layouts");
      qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickLayoutsPlugin().instance()) ->initializeEngine( &engine, "QtQuick.Layouts");
      qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2WindowPlugin().instance()) ->initializeEngine( &engine, "QtQuick.Window.2");
      

      #endif

      ……

      return app.exec( );
      }
      @

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vovatool
        wrote on last edited by
        #3

        Hope this helps http://lemirep.wordpress.com/2013/06/01/deploying-qt-applications-on-linux-and-windows-3/

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved