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. [SOLVED]Qt Plugin metadata
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Qt Plugin metadata

Scheduled Pinned Locked Moved General and Desktop
18 Posts 6 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #1

    I'm working on create my own Qt plugin based application (as used in Echo Plugin and Plug & Paint Examples) but I couldn't know to to monitor versions of my plugins.

    Where I've to store plugin metadata for versioning it?

    As I know Plugin.json file is the place where I can store metadata of the plugin so I input the following:
    @{
    "name" : "pluginA",
    "version" : "0.0.1",
    "dependencies" : []
    }@

    but I failed to load it through:
    @pluginLoader.metaData().value("name").toString();
    pluginLoader.metaData().value("version").toString();@

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

      You could define an int version() call in your interface:

      @
      abstract int version()=0;
      @

      and override this in your derived Plugin.
      I know this is not what you asked for, but it would solve your problem. I don't know how to use the plugin metadata.

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

        Hi,

        Did you add the Q_PLUGIN_METADATA line in your plugin header ?

        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
        • M Offline
          M Offline
          mbnoimi
          wrote on last edited by
          #4

          [quote author="MichelS" date="1372677981"]You could define an int version() call in your interface:

          @
          abstract int version()=0;
          @

          and override this in your derived Plugin.[/quote]

          Actually this is first solution pinged in head but I want to kknow how to get benefit of Plugin Metadata

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbnoimi
            wrote on last edited by
            #5

            [quote author="SGaist" date="1372680937"]Hi,

            Did you add the Q_PLUGIN_METADATA line in your plugin header ?[/quote]

            Sure,

            @class MyPlugin : public QObject, Interface
            {
            Q_OBJECT
            #if QT_VERSION >= 0x050000
            Q_PLUGIN_METADATA(IID "ly.ecs.plugin.0.0.2" FILE "Plugin.json")
            Q_INTERFACES(Interface)
            #endif // QT_VERSION >= 0x050000

            public:
            MyPlugin(QObject parent = 0);
            QPushButton
            someObject(QWidget *parent=0);
            };@

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Buggy
              wrote on last edited by
              #6

              Based on my own experience I am kind of skeptical whenever those macros are involved. Have you tried to re-run qmake (Build - run qmake)? For me, this fixed an error I had been chasing for over an hour...

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbnoimi
                wrote on last edited by
                #7

                [quote author="Buggy" date="1372753860"]Based on my own experience I am kind of skeptical whenever those macros are involved. Have you tried to re-run qmake (Build - run qmake)? For me, this fixed an error I had been chasing for over an hour...[/quote]

                sure I did.
                I'm asking about the principle not fixing a problem.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbnoimi
                  wrote on last edited by
                  #8

                  I'm still stick to this issue and couldn't find any way to fix it. I need metadata to be able to read plugin information before loading it which metadata offers it.

                  P.S. I'm using Qt 5.1

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

                    Hi,

                    Did you dump the content of pluginLoader.metaData() ?

                    I just tried with a simple plugin and got the value of name using:
                    @pluginLoader.metaData().value("MetaData").toObject().value("name").toString();@

                    Also don't forget to "touch" the plugin header file before rebuilding to take the json file modifications in account.

                    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
                    • D Offline
                      D Offline
                      dbzhang800
                      wrote on last edited by
                      #10

                      As AGalst suggested, you forget the key "MetaData" if you want to get access the json file contents passed in the Q_PLUGIN_METADATA. Other information such as IID can be access through the key "IID" etc.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mbnoimi
                        wrote on last edited by
                        #11

                        Thanks a lot guys, it works fine.

                        I wonder does this info mentioned in Qt docs?

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

                          You're welcome !

                          From the ones I searched through, no, this call for an update to the documentation

                          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
                          • M Offline
                            M Offline
                            mbnoimi
                            wrote on last edited by
                            #13

                            [quote]From the ones I searched through, no, this call for an update to the documentation[/quote]

                            Usually I create wiki page for missing docs but because I haven't the suitable knowledge about Qt Plugins, May you please create a wiki page.

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

                              Correction to the doc would have a wider impact. Can you point me to your wiki entries so I can see what would be a good addition to the official documentation ?

                              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
                              • M Offline
                                M Offline
                                mbnoimi
                                wrote on last edited by
                                #15

                                bq. Can you point me to your wiki entries

                                I didn't write any entries I just suggested to add them by you.

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

                                  For the quick road, I have added a doc note

                                  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
                                  • M Offline
                                    M Offline
                                    mbnoimi
                                    wrote on last edited by
                                    #17

                                    [quote author="SGaist" date="1375821248"]For the quick road, I have added a doc note[/quote]

                                    Thanks a lot :)

                                    1 Reply Last reply
                                    0
                                    • K Offline
                                      K Offline
                                      kshots
                                      wrote on last edited by
                                      #18

                                      Definately much appreciated. I was trying to use the new metadata interface for the same reasons, and found the same lack of details in the docs. I have my own implementation working properly now (thanks to this thread), but it would be nice to have some references in the docs about this metadata and json structure.

                                      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