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. Load Custom Positioning Plugin for PositionSource
Forum Updated to NodeBB v4.3 + New Features

Load Custom Positioning Plugin for PositionSource

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 4 Posters 2.9k 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.
  • G Offline
    G Offline
    guicc
    wrote on last edited by guicc
    #1

    I am trying to use PositionSource in my Map project so that I can receive Latitude/Longitude data from another software in my network and update my map.

    So I have done the following:

    1. Created a custom Positioning plugin by implementing QGeoPositionInfoSourceFactory
      1.1) This Plugin implements a class that inherits QGeoPositionInfoSource and emits positionUpdated on my custom method that retrives data from the network.

    2. Added the plugin (dll) and a qmldir file to my QML project working directory
      qmldir file:

    module MyPosition
    plugin MyPositionPlugin
    
    1. Tried inserting my plugin into PositionSource:
    PositionSource {
        id: positionSrc
        updateInterval: 100 //ms
        name: "MyPositionPlugin"
    
        onPositionChanged: {...}
    }
    

    PROBLEM: onPositionChanged does not get called in PositionSource and when listing QGeoPositionInfoSource::availableSources() on my main, it does not list my plugin.

    P.S.: The plugin has the following MetaData in a json:

    {
        "Keys": ["SpectraPositionPlugin"],
        "Provider": "SpectraTecnologia",
        "Position": true,
        "Satellite": false,
        "Monitor": false,
        "Priority": 1000,
        "Testable": true
    }
    

    P.S.S: If I load the plugin using QPluginLoader on a regular Qt/C++ project, it works. The problem is with QML auto loader of plugins

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Silly question but did you install your plugin in the right folder of your Qt's installation ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        always do 'make install' for Qt plugins

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Silly question but did you install your plugin in the right folder of your Qt's installation ?

          G Offline
          G Offline
          guicc
          wrote on last edited by
          #4

          @SGaist
          I was initially deploying my plugin in the Working Directory of my QML project. Now I have tried in the position directory inside Qt installation directory, but to no avail.

          In the project I am printing QQmlApplicationEngine::pluginPathList() which returns:
          (".")
          And then I am checking the loaded plugins withQGeoPositionInfoSource::availableSources();

          I have also tried:

          1. Defining the environment variable QT_PLUGIN_PATH
          2. Created a position directory inside my working directory

          @vladstelmahovsky
          What do you mean by make install?
          After building my plugin project and generating a DLL, where should I do a make install?

          V 1 Reply Last reply
          0
          • G guicc

            @SGaist
            I was initially deploying my plugin in the Working Directory of my QML project. Now I have tried in the position directory inside Qt installation directory, but to no avail.

            In the project I am printing QQmlApplicationEngine::pluginPathList() which returns:
            (".")
            And then I am checking the loaded plugins withQGeoPositionInfoSource::availableSources();

            I have also tried:

            1. Defining the environment variable QT_PLUGIN_PATH
            2. Created a position directory inside my working directory

            @vladstelmahovsky
            What do you mean by make install?
            After building my plugin project and generating a DLL, where should I do a make install?

            V Offline
            V Offline
            vladstelmahovsky
            wrote on last edited by
            #5

            @guicc yes

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              The plugin should go in Qt's installation's location plugins folder.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply
              0
              • SGaistS SGaist

                The plugin should go in Qt's installation's location plugins folder.

                G Offline
                G Offline
                guicc
                wrote on last edited by
                #7

                @SGaist said:

                The plugin should go in Qt's installation's location plugins folder.

                I noticed a new clue to the problem. When activating the QT_DEBUG_PLUGINS environment variable, I had seen that my plugin is found:

                Found metadata in lib C:/Qt/Qt5.6.0_x86/5.6/msvc2013/plugins/position/MyPlugin.dll, metadata=
                {
                    "IID": "com.br.myplugin",
                    "MetaData": {
                        "Keys": [
                            "MyPlugin"
                        ],
                        "Monitor": false,
                        "Position": true,
                        "Priority": 1008,
                        "Provider": "Me",
                        "Satellite": false
                    },
                    "className": "PluginFactory",
                    "debug": false,
                    "version": 329216
                }
                

                But right after it prints the following: Got keys from plugin meta data ()

                While that for other plugins I get: Got keys from plugin meta data ("SerialPortNmea")

                I have already copied and written this plugin.json file 1000 times. Don't know what is wrong!

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  guicc
                  wrote on last edited by
                  #8

                  I managed to solve this problem by copying my code inside the Qt Source code. Since plugin serialnmea works, I opened the project for this plugin at %QT_SRC%\qtlocation\src\plugins\position and replaced the methods and classes with mine.

                  At the end the code structure had one difference:

                  • My QGeoPositionInfoSource source declaration and definition is now placed together with the definition of my QGeoPositionInfoSourceFactory, inside a single .cpp file

                  The project .pro file also has a definition than it is not clearly specified in the Qt Documentation:

                  TARGET = MyPositionPlugin
                  QT = core positioning network
                  
                  PLUGIN_TYPE = position
                  PLUGIN_CLASS_NAME = PositionFactory
                  load(qt_plugin)         #this is the macro that modifies Makefile so that
                                          #it copies the final .dll to the Qt installation dir
                                          #in order for this to work, we also need a .qmake.conf file  
                  
                  HEADERS += \
                      qgeopositioninfosourcefactory_serialnmea.h 
                  
                  SOURCES += \
                      qgeopositioninfosourcefactory_serialnmea.cpp 
                  
                  OTHER_FILES += \
                      plugin.json
                  
                  

                  Another important point that could be better explained in the Documentation: It is not the plugin key that should be inserted on PositionSource, it is the provider!!

                  This property holds the unique internal name for the plugin currently providing position information.
                  ....
                  If the specified positioning **provider** cannot be loaded the position source will become invalid.
                  
                  avinashA 1 Reply Last reply
                  0
                  • G guicc

                    I managed to solve this problem by copying my code inside the Qt Source code. Since plugin serialnmea works, I opened the project for this plugin at %QT_SRC%\qtlocation\src\plugins\position and replaced the methods and classes with mine.

                    At the end the code structure had one difference:

                    • My QGeoPositionInfoSource source declaration and definition is now placed together with the definition of my QGeoPositionInfoSourceFactory, inside a single .cpp file

                    The project .pro file also has a definition than it is not clearly specified in the Qt Documentation:

                    TARGET = MyPositionPlugin
                    QT = core positioning network
                    
                    PLUGIN_TYPE = position
                    PLUGIN_CLASS_NAME = PositionFactory
                    load(qt_plugin)         #this is the macro that modifies Makefile so that
                                            #it copies the final .dll to the Qt installation dir
                                            #in order for this to work, we also need a .qmake.conf file  
                    
                    HEADERS += \
                        qgeopositioninfosourcefactory_serialnmea.h 
                    
                    SOURCES += \
                        qgeopositioninfosourcefactory_serialnmea.cpp 
                    
                    OTHER_FILES += \
                        plugin.json
                    
                    

                    Another important point that could be better explained in the Documentation: It is not the plugin key that should be inserted on PositionSource, it is the provider!!

                    This property holds the unique internal name for the plugin currently providing position information.
                    ....
                    If the specified positioning **provider** cannot be loaded the position source will become invalid.
                    
                    avinashA Offline
                    avinashA Offline
                    avinash
                    wrote on last edited by
                    #9

                    how to run run python script in qt 4.8 version?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Hi and welcome to devnet,

                      What does your question have to do with this thread ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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