Results 1 to 8 of 8

Thread: Is it possible to create a plugin interface that uses inheritance?

  1. #1
    Join Date
    Jul 2007
    Location
    New York
    Posts
    45
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Is it possible to create a plugin interface that uses inheritance?

    if I have a plugin interface that inherits from another class, how do I get plugins compiled with the interface to link (LIB) to the inherited class?

    I want to have something like

    class AInterface : public B
    {
    virtual ~AInterface() {}
    }

    Q_DECLARE_INTERFACE(AInterface, "blah")

    which compiles fine but won't load, seems to have silent linker errors in QPluginLoader with class B.

  2. #2
    Join Date
    Jul 2007
    Location
    Russia, Ul'yanovsk
    Posts
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    I think that is not good idea to inherit interface from a concrete class. You probably should to revise your architecture.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    Just make B inherit the interface, not the other way round.

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    Plugins can't access members/methods of a class that is defined in the application that load them. If B was a Qt class (and not extended in any way within your app) you could use that inheritance scheme. Otherwise you have two solutions left : drop it and use a new design or put the B class ( and it's dependencies) into a shared library that will be accessible to both the application and the plugins since both could link to it...
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5
    Join Date
    Jul 2007
    Location
    New York
    Posts
    45
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    If I was to create a shared library, I'm guessing it would make sense for both the application and the plugin to link to the shared dylib instead of the app compiling it in and the plugin linking.

    Would I create a dylib by using the TEMPLATE=lib (with CONFIG=?something?) method or is there another way?

  6. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    Quote Originally Posted by themolecule View Post
    Would I create a dylib by using the TEMPLATE=lib (with CONFIG=?something?) method or is there another way?
    That's the way. Add "shared" and/or "dll" to the CONFIG var to make sur you don't get a static build...
    Current Qt projects : QCodeEdit, RotiDeCode

  7. The following user says thank you to fullmetalcoder for this useful post:

    themolecule (22nd August 2007)

  8. #7
    Join Date
    Jul 2007
    Location
    New York
    Posts
    45
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    Thanks!

    And I'm guessing that in the app and the plugin, I include the header for my shared library and include the dylib in the LIBS .pro setting (not include the source cpp in either). This has nothing to do with QPluginLoader and I will have to use otool and install_name_tool to move things for deployment. Is that right?

  9. #8
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to create a plugin interface that uses inheritance?

    Quote Originally Posted by themolecule View Post
    And I'm guessing that in the app and the plugin, I include the header for my shared library and include the dylib in the LIBS .pro setting (not include the source cpp in either). This has nothing to do with QPluginLoader and I will have to use otool and install_name_tool to move things for deployment. Is that right?
    That's right (though I can't help you with Mac deployment issues...). You may also need to change your INCLUDEPATH acordingly.
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 15:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.