Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Static plugins for qml app

Static plugins for qml app

Scheduled Pinned Locked Moved Installation and Deployment
2 Posts 1 Posters 2.1k 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.
  • M Offline
    M Offline
    mib383
    wrote on last edited by
    #1

    Hello all.
    I want to include static plugins in my qml project. As i understand i need to use <QtPlugin> and <QQmlExtensionPlugin>.
    When I create QtQuick2 project without QtQuick.Controls it works fine with static plugins:
    qml:
    @
    import QtQuick 2.2
    //import QtQuick.Controls 1.1

    Rectangle{
    width: 200
    height: 200
    color: "LightGreen"
    }
    @
    cpp:
    @
    #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");

    QQuickView viewer;
    viewer.engine()->setImportPathList(QStringList());
    viewer.setSource(QUrl(QStringLiteral("qrc:///main.qml")));
    viewer.show();
    
    return app.exec&#40;&#41;;
    

    }
    @

    But when i try to use QtQuick.Controls...
    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("Exit2")
                onTriggered: Qt.quit();
            }
        }
    }
    
    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
    

    }
    @
    cpp:
    @
    #include <QApplication>
    #include <QQmlApplicationEngine>

    #include <QtPlugin>
    #include <QQmlExtensionPlugin>

    Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
    Q_IMPORT_PLUGIN(QtQuick2Plugin)
    Q_IMPORT_PLUGIN(QtQuickControlsPlugin)
    Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
    Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)

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

    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");
    
    QQmlApplicationEngine engine;
    engine.setImportPathList(QStringList());
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
    
    return app.exec(&#41;;
    

    }
    @

    In this case i get error: "ContentItem is not a type". I know that ContentItem is qml type from QtQuick.Controls.Private. And i assume that i did incorrect type registration for this namespace.

    How can i solve this problem?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mib383
      wrote on last edited by
      #2

      still no answers...

      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