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:
#include <QObject>
#include <QList>
#include <QTcpSocket>
#include <QPluginLoader>
/**
@author Richard F. Ostrow Jr. <kshots@warfaresdl.com>
*/
class formBasePlugin
: public QObject{
Q_OBJECT
public:
formBasePlugin
(QObject * parent
= 0);
virtual ~formBasePlugin();
int row();
virtual const QString pluginName
()const = 0;
virtual void onActivate() = 0;
QList <formBasePlugin
*> listChildren;
void unload(){emit removed();}
protected:
signals:
void removed();
public slots:
};
Q_DECLARE_INTERFACE(formBasePlugin, "evilrpg.warfaresdl/1.0")
#include <QObject>
#include <QList>
#include <QTcpSocket>
#include <QPluginLoader>
class QWorkspace;
/**
@author Richard F. Ostrow Jr. <kshots@warfaresdl.com>
*/
class formBasePlugin : public QObject
{
Q_OBJECT
public:
formBasePlugin(QObject * parent = 0);
virtual ~formBasePlugin();
int row();
virtual const QString pluginName()const = 0;
virtual void onActivate() = 0;
QList <formBasePlugin *> listChildren;
void unload(){emit removed();}
static QTcpSocket socketServer;
static QWorkspace * ws;
QPluginLoader * PL;
protected:
signals:
void removed();
public slots:
};
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:
#include <formBasePlugin.h>
/**
@author Richard F. Ostrow Jr. <kshots@warfaresdl.com>
*/
class pluginWhiteboard : public formBasePlugin
{
Q_OBJECT
Q_INTERFACES(formBasePlugin)
public:
pluginWhiteboard
(QObject * parent
= 0);
virtual ~pluginWhiteboard();
virtual const QString pluginName
()const{return tr
("Whiteboard");
} virtual void onActivate();
};
#include <formBasePlugin.h>
/**
@author Richard F. Ostrow Jr. <kshots@warfaresdl.com>
*/
class pluginWhiteboard : public formBasePlugin
{
Q_OBJECT
Q_INTERFACES(formBasePlugin)
public:
pluginWhiteboard(QObject * parent = 0);
virtual ~pluginWhiteboard();
virtual const QString pluginName()const{return tr("Whiteboard");}
virtual void onActivate();
};
To copy to clipboard, switch view to plain text mode
... and the implementation of said plugin:
Q_EXPORT_PLUGIN2(plugins, pluginWhiteboard)
pluginWhiteboard
::pluginWhiteboard(QObject * parent
) : formBasePlugin
(parent
){
setObjectName("pluginWhiteboard");
}
pluginWhiteboard::~pluginWhiteboard()
{
}
void
pluginWhiteboard::onActivate()
{
}
Q_EXPORT_PLUGIN2(plugins, pluginWhiteboard)
pluginWhiteboard::pluginWhiteboard(QObject * parent) : formBasePlugin(parent)
{
setObjectName("pluginWhiteboard");
}
pluginWhiteboard::~pluginWhiteboard()
{
}
void
pluginWhiteboard::onActivate()
{
}
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.
Bookmarks