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. Looking for Q_PLUGIN_METADATA explain.
Forum Updated to NodeBB v4.3 + New Features

Looking for Q_PLUGIN_METADATA explain.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.6k 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.
  • L Offline
    L Offline
    lygstate
    wrote on last edited by
    #1

    @
    class BasicToolsPlugin : public QObject,
    public BrushInterface,
    public ShapeInterface,
    public FilterInterface
    {
    Q_OBJECT
    //! [4]
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json")
    //! [4]
    Q_INTERFACES(BrushInterface ShapeInterface FilterInterface)
    @

    I want to know hot to setting Q_PLUGIN_METADATA'IID.
    At the code demo before, there is three interface (BrushInterface, ShapeInterface, FilterInterface);
    and the Q_PLUGIN_METADATA use the BrushInterface. So is that BrushInterface is the only choice for BasicToolsPlugin
    is there any reason for this choice?
    Why we needd to specify the Interface IID for Q_PLUGIN_METADATA, indeed, we can retrieve BrushInterface IID through
    from Q_INTERFACES(BrushInterface ShapeInterface FilterInterface).

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Hi,

      The plugin IID has nothing todo with the INTERFACES IID.

      plugin IID is used to determine whether the plugin is your needed or not.

      while interface IID is used in qobject_cast().

      You can take a look at http://blog.debao.me/2013/06/qt-macro-q-declare-interface/

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lygstate
        wrote on last edited by
        #3

        That's great, the misunderstanding comes from
        http://qt-project.org/doc/qt-5.1/qtcore/plugins-howto.html
        @
        class MyStylePlugin : public QStylePlugin
        {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE mystyleplugin.json)
        public:
        QStyle *create(const QString &key);
        };
        @
        and

        @
        #include <QObject>
        #include <QtPlugin>
        #include <QStringList>
        #include <QImage>

        #include <plugandpaint/interfaces.h>

        class ExtraFiltersPlugin : public QObject, public FilterInterface
        {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface" FILE "extrafilters.json")
        Q_INTERFACES(FilterInterface)

        public:
        QStringList filters() const;
        QImage filterImage(const QString &filter, const QImage &image,
        QWidget *parent);
        };
        @

        I hope that will be modified.

        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