Results 1 to 6 of 6

Thread: How to determine the name of the interface in Qt plugins?

  1. #1
    Join Date
    May 2011
    Posts
    30
    Thanks
    1

    Default How to determine the name of the interface in Qt plugins?

    How to determine the name of the interface in Qt plugins?
    I try to use InterfaceClass* b = qobject_cast<InterfaceClass*>(PluginLoader.instanc e()) as was suggested in qt assistant. But when I load plugins with another interface, qobject_cast returns a valid pointer and program later crashes with Illegal Instruction signal when I try to use methods of class b. Maybe someone can suggest something.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to determine the name of the interface in Qt plugins?

    make sure you didn't forget to Q_OBJECT macro in your plugin implementation class header.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2011
    Posts
    30
    Thanks
    1

    Default Re: How to determine the name of the interface in Qt plugins?

    Yes, Q_OBJECT is inside my plugin class. Did anyone face this problem? When I try to load plugins from plug&paint example everything works ok, my program rejects to use them, but when I try to use my own plugins from my different programs, the program crashes.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to determine the name of the interface in Qt plugins?

    The name of the interface(s) supported by your plugin will the ones named in Q_INTERFACES() macros as described in the plugin documentation.

    The interfaces exported by plugins provided as part of Qt are documented under Plugin Classes in Assistant. Unless you are writing a new instance of, for example, an SQL driver then you should probably never need this information.

  5. #5
    Join Date
    May 2011
    Posts
    30
    Thanks
    1

    Default Re: How to determine the name of the interface in Qt plugins?

    Where "Identifer" in macro Q_DECLARE_INTERFACE ( ClassName, Identifier ) is used and why it must be unique?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to determine the name of the interface in Qt plugins?

    It is used as part of Qt's checks that the actual plugin dynamic library exported interface and the interface that the program is expecting to see are the same. If your program has a series of versions over time and the plugin interface changes then this identifier should change. Clearly it is good if the identifier you use is not the same as the identifier used by anyone else so you cannot accidentally load an incompatible plugin and crash your program.

    Other checks that Qt does are checks of compiler compatibility between you application and your plugin.

Similar Threads

  1. Determine the Process ID
    By Jimmy2775 in forum General Programming
    Replies: 5
    Last Post: 7th October 2011, 09:16
  2. Replies: 17
    Last Post: 2nd January 2011, 17:11
  3. How to determine type of cd?
    By AlexanderPopov in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2010, 09:20
  4. Mac OS, plugins that user designer plugins
    By Royceybaby in forum Qt Programming
    Replies: 0
    Last Post: 9th May 2010, 01:40
  5. How to determine if my app is active...
    By Ben.Hines in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 16:02

Tags for this Thread

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.