Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Qt Quick 2 Extension Plugin
Forum Updated to NodeBB v4.3 + New Features

Qt Quick 2 Extension Plugin

Scheduled Pinned Locked Moved German
11 Posts 2 Posters 8.8k 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.
  • D Offline
    D Offline
    danut.iurascu
    wrote on last edited by
    #2

    First of all you need to ensure that your plugin is installed correctly.
    QtCreator will use this plugin for auto-complition, and syntax validation during development.

    you just have to copy *.so, qmldir and plugins.qmltypes it the location C:\Qt\Qt5.0.0\5.0.0\msvc2010\imports\firsttest

    if your plugin is named "com.example.firsttest", than you have to create the entire directory tree
    C:\Qt\Qt5.0.0\5.0.0\msvc2010\imports\com\example\firsttest

    this should fix your issue. it worked for me.

    regards,
    Dănuț

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alpha-kilo
      wrote on last edited by
      #3

      Thank you for your response,

      my plugin is named "firsttest". I build the .dll, ..d.dll files and the plugins.qmltypes at C:\Qt\Qt5.0.0\5.0.0\msvc2010\imports\firsttest. (DESTDIR = $$[QT_INSTALL_IMPORTS]/firsttest) Then I copied qmldir to this location. After this I modified qmldir and inserted "typeinfo plugins.qmltypes".

      In the QtQuick2 projects main.qml file I imported the plugin with "import firsttest 1.0" If I hover with the mouse over the import command the creator shows that there is a library at the location C:\Qt\Qt5.0.0\5.0.0\msvc2010\imports\firsttest and typeinfo file is read.

      Then I can bild the project. The execution stops with the message ""module "firsttest" is not installed "" import firsttest 1.0

      Now I changed the directory and the name of the plugin to "com.example.firsttest", made a new build at com.example.firsttest, copied qmldir to /imports/com/example/firsttest. In my main.qml file I changed the import command to "import com.example.firsttest 1.0" the creator finds the library but the execution fails with the same error message.

      I also tried to use different names for module, plugin and class but it makes no difference.

      I dont know, what I can do anymore.

      regards,
      andré

      regards,
      andré

      1 Reply Last reply
      0
      • D Offline
        D Offline
        danut.iurascu
        wrote on last edited by
        #4

        in your main.cpp file you can set the import path manualy
        viewer.engine()->setImportPath("location to your library");

        seems like the variable from *.pro is not taken into consideration.

        regards,
        Dănuț

        1 Reply Last reply
        0
        • D Offline
          D Offline
          danut.iurascu
          wrote on last edited by
          #5

          I have no clue why QML_IMPORT_PATH does not work as expected, but at least there is a workaround

          regards,
          Dănuț

          1 Reply Last reply
          0
          • D Offline
            D Offline
            danut.iurascu
            wrote on last edited by
            #6

            You can modify your main.cpp, like below, and should work.
            the method used is addImportPath, not setImportPath as I previously said

            @
            #include <QtGui/QGuiApplication>
            #include "qtquick2applicationviewer.h"

            int main(int argc, char *argv[])
            {
            QGuiApplication app(argc, argv);
            QtQuick2ApplicationViewer viewer;
            viewer->engine()->addImportPath("<your_path>");
            viewer.setMainQmlFile(QStringLiteral("qml/Test/main.qml"));
            viewer.showExpanded();

            return app.exec();
            }@

            regards,
            Dănuț

            regards,
            Dănuț

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alpha-kilo
              wrote on last edited by
              #7

              hello dănuț,

              thanks for your effort. the code you posted is exatly the same i tried yesterday in the evening with the same result as before.
              today in the morning i tested the code on ubuntu with qt5 and gcc64. i thought it is a problem of the .dll but the result was also the same on linux with the .so file.
              now i think there must be somthing wrong with the plugin code or with qt5 itself.
              have you ever used qt5 with the "Qt Quick 2 Extension Plugin" wizard with a executable result? if so can you send me please your sources including the .pro files.

              an other question at the macro "Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")". im not sure what iid i have to use. can i use "org.qt-project.Qt.QQmlExtensionInterface"? the tutorial says i have to use a unique id. whitch rules i have to observe and what does it mean when i use "aaa.bbb.ccc.ddd"

              regards,
              andré

              regards,
              andré

              1 Reply Last reply
              0
              • D Offline
                D Offline
                danut.iurascu
                wrote on last edited by
                #8

                Hi,
                According with the documentation, the ID just have to be unique
                @Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDummyPlugin" FILE "mymetadata.json")@

                In my test I have left the IID as it was generated (org.qt-project.Qt.QQmlExtensionInterface).
                In my workarea I have created 2 projects
                QtQuick2ExtentionPlugin
                and
                QtQuick2Application

                QtQuick2ExtentionPlugin project was generated using wizard, and I felt it as it was generated entirely.
                QtQuick2Application project was also generated using wizard, and than I have modified
                main.qml
                @import QtQuick 2.0
                import com.mycompany.qmlcomponents 1.0

                Rectangle {
                width: 360
                height: 360
                Text {
                text: qsTr("Hello World")
                anchors.centerIn: parent
                }
                MouseArea {
                anchors.fill: parent
                onClicked: {
                Qt.quit();
                }
                }
                MyItem
                {

                }
                

                }@

                and mai.cpp
                @
                #include <QtGui/QGuiApplication>
                #include "qtquick2applicationviewer.h"
                #include <QQmlEngine>

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

                QtQuick2ApplicationViewer viewer;
                //location to your plugin
                viewer.engine()->addImportPath("/###/Qt5.0.0/5.0.0/gcc/imports");
                viewer.setMainQmlFile&#40;QStringLiteral("qml/QtQuick2Application/main.qml"&#41;);
                
                viewer.showExpanded();
                
                return app.exec();
                

                }@

                than I have created next directory tree
                Qt5.0.0/5.0.0/gcc/imports/com/mycompany/qmlcomponents
                and copy inside qmldir and libQtQuick2ExtensionPlugin.so which were created when QtQuick2ExtentionPlugin was build.

                When QtQuick2Application is build and run, everything works just right.

                regards,
                Dănuț

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alpha-kilo
                  wrote on last edited by
                  #9

                  hello dănuț,

                  thanks again. i uninstalled Qt installed it again and then I tried to create the two projects with the the wizard setup, created the dir tree, copied the files and created the typeinfofile. then i modified the main.cpp ... unfortunately the same result.

                  can you tell me which creator you use? i use 2.6.1 rvv 8d02f18140 with Qt5 final
                  have you changed something at the build environmet?
                  which switches you use for qmake / make?

                  many thanks

                  regards,
                  andré

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    danut.iurascu
                    wrote on last edited by
                    #10

                    Hi andré,
                    my environment is similar with what you have..
                    Ubuntu 12.10 (x64)
                    Qt Creator 2.6.1 with Qt5.0.0 final

                    http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/qdeclarativemodules.html this was the first tutorial I have follow.

                    bq. The import path, as returned by QDeclarativeEngine::importPathList(), defines the default locations to be searched by the QML engine for a matching module. By default, this list contains:

                    • The directory of the current file
                    • The location specified by QLibraryInfo::ImportsPath
                    • Paths specified by the QML_IMPORT_PATH environment variable

                    having in mind that the current folder is the first one in which it search for your plugin, you can try to create the same directory tree inside your QtQuickApplication (or better a symlink to "com" folder )
                    (this solution works for me also)

                    regards,
                    dănuț

                    regards,
                    Dănuț

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alpha-kilo
                      wrote on last edited by
                      #11

                      hello dănuț,

                      very thanks for your efforts to help me. finaly i solved the problem.
                      i included "qputenv("QML_IMPORT_TRACE", "1");" to see which paths are included. then i saw that there are only 3 paths are included regardless of which paths i try to include with addImportPath or QML_IMPORT_PATH.

                      1. QQmlImportDatabase::addImportPath: "C:\Qt\Qt5.0.0\5.0.0\msvc2010\qml"
                      2. QQmlImportDatabase::addImportPath: "../test1-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug/release"
                      3. QQmlImportDatabase::addImportPath: "../test1-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release/debug"

                      "C:\Qt\Qt5.0.0\5.0.0\msvc2010\imports" is not included and the paths #2 and #3 are emty. if i build a release version the path to the application is ... 32bit_SDK-Release/relase and not 32bit_SDK-Release/debug. this paths is created indeed but emty and if i build the debug version it is similar. so the linker can never find the module under ../imports/com/mycompany/qmlcomponents or ...Debug/debug/com/mycompany/qmlcomponents.

                      Now i created the tree com/mycompany/qmlcomponents at this "wrong" path and everything works just right.
                      I dont know why i cant add a import path maybe i is an issue of the creator or i dont have the rights to change some files in the qt environment (but i started the creator as admin). i hope it works with the next version of the creator.

                      thank you very much,
                      andré

                      regards,
                      andré

                      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