Results 1 to 5 of 5

Thread: Why can Qt Creator use QPluginLoader to load plugins?

  1. #1
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Why can Qt Creator use QPluginLoader to load plugins?

    I'm new to qt,forgive me if this is a stupid question.

    I checked the qt creator source code.And noticed that in the libs/extensionsystem/pluginspec.cpp, it use QPluginLoader to load the dll file.The plugins are subclasses of IPlugin.

    I also read the help/tutorial,isn't that we have to use some macros like,Q_EXPORT_PLUGIN2(),Q_INTERFACES() if we want to create application plugins?And if we don't use these macros,the QPluginLoader won't load the dll file,right?

    So,in the qtcreator,how does the PluginSpec class enable to load the plugin dll files with QPluginLoader?
    It's not the goodbye that hurts,but the flashback that follow.

  2. #2
    Join Date
    Aug 2009
    Posts
    23
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why can Qt Creator use QPluginLoader to load plugins?

    Q_INTERFACES and Q_DECLARE_INTERFACE enable qobject_cast to interface, ie IFace * face = qobject_cast<IFace *>(pluginClass);
    If pluginClass inherits QObject, these macroses are not needed.
    But Q_EXPORT_PLUGIN2 or Q_EXPORT_PLUGIN creates functions that are exported from plugin - these functions create instance of your exported class. Yes, without one of them plugin won't work.

  3. #3
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why can Qt Creator use QPluginLoader to load plugins?

    But qt creator didn't use these macros...lol
    It's not the goodbye that hurts,but the flashback that follow.

  4. #4
    Join Date
    Aug 2009
    Posts
    23
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why can Qt Creator use QPluginLoader to load plugins?

    in qtcreator all interfaces are subclasses of QObject - they don't need first macro
    and second is used: file src/plugins/bineditor/bineditorplugin.cpp
    Qt Code:
    1. Q_EXPORT_PLUGIN(BinEditorPlugin)
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to ABBAPOH for this useful post:

    MorrisLiang (25th April 2010)

  6. #5
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why can Qt Creator use QPluginLoader to load plugins?

    OK,I miss that part,Thanks for pointing that out.I'll check for that..
    It's not the goodbye that hurts,but the flashback that follow.

Similar Threads

  1. Designer plugins in Qt Creator
    By stefan in forum Qt Tools
    Replies: 9
    Last Post: 8th March 2010, 06:51
  2. Qt Creator doesn't load nested plugin
    By skepticalgeek in forum Qt Tools
    Replies: 0
    Last Post: 9th January 2010, 22:10
  3. Replies: 8
    Last Post: 27th December 2009, 15:57
  4. Replies: 0
    Last Post: 30th August 2009, 23:44
  5. QPluginLoader doesn't load plugin
    By BeS in forum Qt Programming
    Replies: 6
    Last Post: 26th November 2008, 20:12

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.