Results 1 to 7 of 7

Thread: Nightmares with plugins

  1. #1
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Nightmares with plugins

    Hello all,

    I'm having a considerable amount of trouble getting my plugins to work. Following the documentation (under the "How to Create Qt Plugins" section), I am following the low-level approach of creating plugins to extend my application through the use of QPluginLoader.

    Currently, the whole mess compiles, but when I try to obtain an instance of my plugin, I get a NULL-pointer.

    Here's what I've got:

    The base plugin header:
    Qt Code:
    1. #include <QObject>
    2. #include <QList>
    3. #include <QTcpSocket>
    4. #include <QPluginLoader>
    5.  
    6. class QWorkspace;
    7.  
    8. /**
    9. @author Richard F. Ostrow Jr. <kshots@warfaresdl.com>
    10. */
    11. class formBasePlugin : public QObject
    12. {
    13. Q_OBJECT
    14. public:
    15. formBasePlugin(QObject * parent = 0);
    16. virtual ~formBasePlugin();
    17.  
    18. int row();
    19.  
    20. virtual const QString pluginName()const = 0;
    21. virtual void onActivate() = 0;
    22.  
    23. QList <formBasePlugin *> listChildren;
    24. void unload(){emit removed();}
    25. static QTcpSocket socketServer;
    26. static QWorkspace * ws;
    27. protected:
    28. signals:
    29. void removed();
    30. public slots:
    31. };
    32.  
    33. Q_DECLARE_INTERFACE(formBasePlugin, "evilrpg.warfaresdl/1.0")
    To copy to clipboard, switch view to plain text mode 
    Then I've got the header for one of the plugins:
    Qt Code:
    1. #include <formBasePlugin.h>
    2.  
    3. /**
    4. @author Richard F. Ostrow Jr. <kshots@warfaresdl.com>
    5. */
    6. class pluginWhiteboard : public formBasePlugin
    7. {
    8. Q_OBJECT
    9. Q_INTERFACES(formBasePlugin)
    10. public:
    11. pluginWhiteboard(QObject * parent = 0);
    12. virtual ~pluginWhiteboard();
    13.  
    14. virtual const QString pluginName()const{return tr("Whiteboard");}
    15. virtual void onActivate();
    16. };
    To copy to clipboard, switch view to plain text mode 
    ... and the implementation of said plugin:
    Qt Code:
    1. Q_EXPORT_PLUGIN2(plugins, pluginWhiteboard)
    2.  
    3. pluginWhiteboard::pluginWhiteboard(QObject * parent) : formBasePlugin(parent)
    4. {
    5. setObjectName("pluginWhiteboard");
    6. }
    7.  
    8. pluginWhiteboard::~pluginWhiteboard()
    9. {
    10. }
    11.  
    12. void
    13. pluginWhiteboard::onActivate()
    14. {
    15. }
    To copy to clipboard, switch view to plain text mode 
    My application successfully finds the plugin (I have checked this), but fails to load said plugin. Am I missing anything blatantly obvious? Thanks.
    Life without passion is death in disguise

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nightmares with plugins

    What is the name of a file that contains this plugin?

  3. #3
    Join Date
    Jan 2007
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Nightmares with plugins

    what system? windows or linux?

  4. #4
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Nightmares with plugins

    Quote Originally Posted by jacek View Post
    What is the name of a file that contains this plugin?
    libplugins.so

    Quote Originally Posted by dcurtis View Post
    what system? windows or linux?
    Both (in the end, at least). Currently testing with unix.
    Life without passion is death in disguise

  5. #5
    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: Nightmares with plugins

    Do you have more than one plugin in the "libplugins" lib? I don't think this is possible... AFAIR you can have only one plugin export macro per plugin.

  6. #6
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Nightmares with plugins

    Quote Originally Posted by wysota View Post
    Do you have more than one plugin in the "libplugins" lib? I don't think this is possible... AFAIR you can have only one plugin export macro per plugin.
    I only have one "libplugins" plugin. This is my first shot at plugins (at least under Qt... I've used ld and libtool ld before), and I had a bit of a misunderstanding that I have not yet corrected. It will end up being libWhiteboard.

    The name of the source file(s) are pluginWhiteboard.[h/cpp]

    And also, because I forgot to post it, the contents of the .pro file for the plugin:
    Qt Code:
    1. # Target is a library: whiteboard
    2.  
    3. QT = network core
    4. INCLUDEPATH += ../src
    5. TARGET = whiteboard
    6. DESTDIR = ../bin/plugins
    7. CONFIG += release \
    8. warn_on \
    9. qt \
    10. plugin
    11. TEMPLATE = lib
    12. HEADERS += pluginWhiteboard.h
    13. SOURCES += pluginWhiteboard.cpp
    To copy to clipboard, switch view to plain text mode 
    Life without passion is death in disguise

  7. #7
    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: Nightmares with plugins

    I think the name you put into the Q_EXPORT_PLUGIN2 macro is wrong.

Similar Threads

  1. Qt plugins - how to do a libtool-style autoload
    By KShots in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2007, 12:40
  2. Plugins support Help!
    By Chaid in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2006, 15:07
  3. Arthur Plugins demos and designer
    By antonio.r.tome in forum Installation and Deployment
    Replies: 4
    Last Post: 21st March 2006, 14:01
  4. Plugins that use *.ui based classes
    By blackliteon in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2006, 09:33
  5. Plugins as small application
    By blackliteon in forum Qt Programming
    Replies: 4
    Last Post: 12th January 2006, 09:39

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.