Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QTPlugin Constructor arguments

    General and Desktop
    2
    4
    1323
    Loading More Posts
    • 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.
    • S
      Suths last edited by

      Hi all, maybe its just been a long day but i can't seem to spot my fault here .

      I'm trying to create a plugin where the constructor interface has some required arguments.

      for example take this

      Interface:
      @
      QT_BEGIN_NAMESPACE
      class QObject;
      QT_END_NAMESPACE

      namespace INTERFACE
      {
           class testInterfacePlugin: public QObject
           {
           public:
      
               testInterfacePlugin(FOO x)
      
               virtual ~testInterfacePlugin(){}
      
           };
      }
      

      QT_BEGIN_NAMESPACE

      #define testInterfacePlugin_iid "testInterfacePlugin"

      Q_DECLARE_INTERFACE(INTERFACE::testInterfacePlugin, testInterfacePlugin_iid)
      @

      Plugin:
      @
      namespace INTERFACE
      {
      class Test_plugin: public INTERFACE:testInterfacePlugin
      {

              Q_OBJECT
              Q_PLUGIN_METADATA(IID "testInterfacePlugin_iid " FILE "test_plugin.json")
              Q_INTERFACES(INTERFACE::testInterfacePlugin)
      
          public:
      
              Test_plugin(FOO x);
      
      
          };
      }
      

      @

      where the JSON file is empty, however when I go to compile this I keep getting a "no matching call to a testInterfacePlugin(FOO)" error message, almost like it can't tell that the interface has that constructor. Has anyone come across this before and do they know how to resolve it.

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        U did not implement constructor for interface. Also don't inherit interface from who jet.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 0
        • S
          Suths last edited by

          Thanks for the response Dheerendra but i'm not sure i follow your statement, the interface has a constructor testInterfacePlugin(FOO x), and i'm not to sure what you meant by "Also don't inherit interface from who jet" would you mind elaborating.
          Thanks
          [quote author="Dheerendra" date="1410112988"]U did not implement constructor for interface. Also don't inherit interface from who jet.[/quote]

          1 Reply Last reply Reply Quote 0
          • dheerendra
            dheerendra Qt Champions 2022 last edited by

            You need implement constructor in interface definition. Don't inherit interface from qobject. Sorry due to some auto completion qobject has become jet. .

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply Reply Quote 0
            • First post
              Last post