Hello everyone,
I am trying to create a plugin that either sets up a widget with controls or returns a QWigdet that will become a child widget of a parent. Bascially I am trying to use QtPlugin to create a MDI app and each plugin will provide a different view.
I am using Qt 4.2.2 Windows Open Source with MinGW as the compiler.
The issue I am running into is I keep getting the following error when trying to compile my test plugin:
moc_myplugin.cpp: undefined reference to 'vtable for MyPluginInterface'
When I take out the setupWidget function everthing works fine and I can even call the gethello function from a test app from the compiled plugin dll.
Thank you in advance for any help .
- Chris
Here is the code for my plugin and interface:
//-----------------------------------
// interface.h
//-----------------------------------
#ifndef INTERFACES_H
#define INTERFACES_H
class QString;
class QWidget;
class MyPluginInterface
{
public:
virtual ~MyPluginInterface() {}
virtual QString gethello() const = 0;
virtual void createWidget(QWidget *parent = 0);
};
Q_DECLARE_INTERFACE(MyPluginInterface, "com.MyPluginInterface/1.0")
#endif //INTERFACES_H
//-----------------------------------
// myplugin.h
//-----------------------------------
#ifndef MYPLUGIN_H
#define MYPLUGIN_H
#include <QObject>
#include <QString>
#include <QWidget>
#include <QPushButton>
#include <QtGui>
#include "interfaces.h"
class MyPlugin : public QObject, public MyPluginInterface
{
Q_OBJECT
Q_INTERFACES(MyPluginInterface)
public:
// MyPluginInterface
MyPlugin(){};
~MyPlugin(){};
QString gethello() const;
void createWidget(QWidget *parent);
};
#endif //MYPLUGIN_H
//-----------------------------------
// myplugin.cpp
//-----------------------------------
#include "myplugin.h"
QString MyPlugin::gethello() const
{
return "Hello World!";
}
void MyPlugin::createWidget(QWidget *parent)
{
}
Q_EXPORT_PLUGIN2(myplugin, MyPlugin)
Bookmarks