rianquinn
22nd January 2006, 21:51
I'm trying to load a custom plugin into an app I am making. This plugin isn't made for QtDesigner, it simply extends the functionality of an existing app. The problem is when I try to load the dll using QPluginLoader, isLoaded is always returing false. Not matter what I try. Here is my current attempts.
Here is my code
#include "main_frmPE.h"
main_frmPE::main_frmPE (QWidget * parent) :
QWidget (parent)
{
setupUi (this);
QPluginLoader menu (QApplication::applicationDirPath() + "/../lib/menu.dll");
if (menu.isLoaded ())
QMessageBox::information (this, "Info","Hello World");
else
QMessageBox::information (this, "Info","Yuk!!");
}
This is the plugin interface
// Define Qt definitions
#include <QtGui>
class Plugin_Interface
{
public:
virtual ~Plugin_Interface () {}
virtual void init () {}
virtual void run () {}
};
Q_DECLARE_INTERFACE (Plugin_Interface, "plugin.programmerseditor.menu/1.0");
and this is the plugin itself
// Define Qt definitions
#include <QtGui>
// Define plugin definitions
#include "../../main/plugins/plugin_interface.h"
class plugin_menu_interface:
public QObject, public Plugin_Interface
{
Q_OBJECT
Q_INTERFACES (Plugin_Interface)
public:
plugin_menu_interface ();
virtual ~plugin_menu_interface ();
void init () {}
void run () {}
};
// Define user definitions
#include "menu_interface.h"
plugin_menu_interface::plugin_menu_interface ()
{
qDebug ("Hello World");
}
plugin_menu_interface::~plugin_menu_interface ()
{
}
I guess the most useful thing would be some working example code on how to do this. Qt's documentation is terrible on this subject. Otherwise, if someone know what I am doing wrong, or has any hints please let me know. I have spent days on this and have had no luck. And I can't find any working code to use as an example. Thanks everyone
Rian
Here is my code
#include "main_frmPE.h"
main_frmPE::main_frmPE (QWidget * parent) :
QWidget (parent)
{
setupUi (this);
QPluginLoader menu (QApplication::applicationDirPath() + "/../lib/menu.dll");
if (menu.isLoaded ())
QMessageBox::information (this, "Info","Hello World");
else
QMessageBox::information (this, "Info","Yuk!!");
}
This is the plugin interface
// Define Qt definitions
#include <QtGui>
class Plugin_Interface
{
public:
virtual ~Plugin_Interface () {}
virtual void init () {}
virtual void run () {}
};
Q_DECLARE_INTERFACE (Plugin_Interface, "plugin.programmerseditor.menu/1.0");
and this is the plugin itself
// Define Qt definitions
#include <QtGui>
// Define plugin definitions
#include "../../main/plugins/plugin_interface.h"
class plugin_menu_interface:
public QObject, public Plugin_Interface
{
Q_OBJECT
Q_INTERFACES (Plugin_Interface)
public:
plugin_menu_interface ();
virtual ~plugin_menu_interface ();
void init () {}
void run () {}
};
// Define user definitions
#include "menu_interface.h"
plugin_menu_interface::plugin_menu_interface ()
{
qDebug ("Hello World");
}
plugin_menu_interface::~plugin_menu_interface ()
{
}
I guess the most useful thing would be some working example code on how to do this. Qt's documentation is terrible on this subject. Otherwise, if someone know what I am doing wrong, or has any hints please let me know. I have spent days on this and have had no luck. And I can't find any working code to use as an example. Thanks everyone
Rian