Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create a plugins
Forum Updated to NodeBB v4.3 + New Features

Create a plugins

Scheduled Pinned Locked Moved General and Desktop
35 Posts 4 Posters 14.7k 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.
  • Z Offline
    Z Offline
    ZapB
    wrote on last edited by
    #19

    I do not see anything in that document relating to qml plugins. Rather than this constant back and forth can you provide a zip file of your two projects that we can try to fix up for you please?

    Nokia Certified Qt Specialist
    Interested in hearing about Qt related work

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goli
      wrote on last edited by
      #20

      i can't post all my code. but this is the main classes:

      1st project :

      ngwidgetsplugin.h

      @#include <QDeclarativeExtensionPlugin>

      class NGWidgetsPlugin: public QDeclarativeExtensionPlugin
      {
      Q_OBJECT
      public:
      void registerTypes(const char *uri);
      };@

      ngwidgetsplugin.cpp

      @#include <QtDeclarative>
      #include <QtPlugin>
      //.....more includes for files

      void NGWidgetsPlugin::registerTypes(const char *uri)
      {
      qmlRegisterType<OperandItem> (uri, 1, 0, "MYOperand");

         //................. 
      

      }

      Q_EXPORT_PLUGIN2(NGWidgets, NGWidgetsPlugin)@

      .pro

      @QT += core gui
      QT += declarative
      QT += network

      #TARGET = NGWidgets
      TEMPLATE = lib
      CONFIG += qt plugin
      DESTDIR = lib
      OBJECTS_DIR = tmp
      MOC_DIR = tmp

      SOURCES += ...
      HEADERS += ...
      OTHER_FILES += ...
      @

      qmldir

      @plugin NGWidgets lib@

      2nd project - use the plugin

      .pro

      @QT += core gui
      QT += declarative
      QT += network

      SOURCES += ...
      HEADERS += ...
      OTHER_FILES += ...@

      qmldir

      @plugin NGWidgets C:/Qt/Projects/NGWidgets-build-desktop/debug @

      app.qml

      @import QtQuick 1.0
      import NGWidgets 1.0

      Rectangle
      {
      MYOperand{...}
      }

      @

      i got the error : module "NGWidgets" is not installed
      for line 2

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #21

        Be also aware that you usually cannot mix release and debug code.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goli
          wrote on last edited by
          #22

          so how can i connect to the plugin, that locate in the debug dir?

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #23

            I just wanted to point out that if you compile your application in debug mode you should compile your plugins in debug mode too (same goes for release builds).

            However - have you tried to "trace the module import":http://developer.qt.nokia.com/doc/qt-4.7/qdeclarativedebugging.html?

            EDIT: Are you sure that path in your qmldir file is correct? You instruct qmake to place your library in a "lib" directory but your path points to the "debug" directory. -As far as I have understood the documentation you do not need both - the qmldir and the import statement. You can omit one.-

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goli
              wrote on last edited by
              #24

              yes, i give the path to the location of NGWidgets.dll , and this dll is locate in the debug dir of the plugin project and also in the lib directory (in 2 cases it's not recognize the "module")...

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lgeyer
                wrote on last edited by
                #25

                The .dll in your debug directory is most likely an outdated version, as all new versions are moved to the lib directory (as specified as DESTDIR in the .pro file). You are pointing to the wrong directory in your qmldir file.

                Have you already tried tracing the module import?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goli
                  wrote on last edited by
                  #26

                  ok - you right , i changed it to :
                  @plugin NGWidgets C:/Qt/Projects/NGWidgets-build-desktop/lib@
                  but still have the same problem

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lgeyer
                    wrote on last edited by
                    #27

                    Have you already tried tracing the module import?

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goli
                      wrote on last edited by
                      #28

                      this is the output:
                      QDeclarativeImportDatabase::addImportPath: "C:\QtSDK\Desktop\Qt\4.7.3\mingw\imports"
                      QDeclarativeImportDatabase::addImportPath: "C:/Qt/Projects/App-build-desktop/debug"
                      QDeclarativeImports(C:/Qt/Projects/App/app.qml)::addImport: "." -1.-1 File as ""
                      QDeclarativeImports(C:/Qt/Projects/App/app.qml)::addImport: "QtQuick" 1.0 Library as ""
                      QDeclarativeImports(C:/Qt/Projects/App/app.qml)::addImport: "NGWidgets" 1.0 Library as ""
                      C:/Qt/Projects/App/app.qml:3:1: module "NGWidgets" is not installed

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goli
                        wrote on last edited by
                        #29

                        is this a good output?

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          lgeyer
                          wrote on last edited by
                          #30

                          Did you place your qmldir file "correctly":http://doc.trolltech.com/4.8-snapshot/qdeclarativemodules.html#installed-modules?

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goli
                            wrote on last edited by
                            #31

                            yes, this is in the main directory of the App project...

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              goli
                              wrote on last edited by
                              #32

                              the dll islocate in the "C:\Qt\Projects\NGWidgets-build-desktop\lib"
                              and the qmldir file is in "C:\Qt\Projects\App"

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goli
                                wrote on last edited by
                                #33

                                can someone post please code of 2 project (one plugin, and one qml application that use the plugin) , when the projects are not under the same build , and it work for him please.

                                1 Reply Last reply
                                0
                                • Z Offline
                                  Z Offline
                                  ZapB
                                  wrote on last edited by
                                  #34

                                  Yup only takes 10 minutes! You can find the projects at:

                                  "Project 1 (the QML plugin)":http://www.theharmers.co.uk/busyindicator.tar.gz
                                  "Project 2 (the app using the plugin)":http://www.theharmers.co.uk/simpleqmlapp.tar.gz

                                  You will need to alter the following things to make it work on your system:

                                  In busyindicator.pro edit the line

                                  @
                                  target.path = $$(HOME)/local/lib
                                  @
                                  to a path of your choice.

                                  In the 2nd project edit the file simpleqmlapp/qml/simpleqmlapp/qmldir so that the path matches what you set in the .pro file above. By default it contains:

                                  @
                                  plugin zapbsqmlplugin /home/sean_harmer/local/lib
                                  @

                                  With the above mods in place, just do:

                                  @
                                  qmake
                                  make
                                  make install
                                  @

                                  in the busyindicator project. Followed by:

                                  @
                                  qmake
                                  make
                                  @

                                  in the simpleqmlapp project.

                                  Nokia Certified Qt Specialist
                                  Interested in hearing about Qt related work

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goli
                                    wrote on last edited by
                                    #35

                                    thank you for all your help. i will check this example :)

                                    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