class Interface
{
public:
Interface() {}
virtual ~Interface() {}
};
class Interface
{
public:
Interface() {}
virtual ~Interface() {}
virtual void Method(QMenuBar* menuBar, QWidget* parent = 0) const = 0;
};
To copy to clipboard, switch view to plain text mode
class Plugin : public Interface
{
Q_OBJECT
public:
Plugin();
~Plugin();
private slots:
void TestSlot();
};
class Plugin : public Interface
{
Q_OBJECT
public:
Plugin();
~Plugin();
void Method(QMenuBar* menuBar, QWidget* parent = 0) const;
private slots:
void TestSlot();
};
To copy to clipboard, switch view to plain text mode
{
connect(pluginAction, SIGNAL(triggered()), parent, SLOT(TestSlot()));
pluginMenu->addAction(pluginAction);
menuBar->addMenu(pluginMenu);
}
void Plugin::Method(QMenuBar* menuBar, QWidget* parent) const
{
QAction *pluginAction = new QAction(tr("SomeText"), parent);
connect(pluginAction, SIGNAL(triggered()), parent, SLOT(TestSlot()));
QMenu *pluginMenu = new QMenu(tr("Plugin"));
pluginMenu->addAction(pluginAction);
menuBar->addMenu(pluginMenu);
}
To copy to clipboard, switch view to plain text mode
I want to use slots in my Plugin so I've added Q_OBJECT but I get these errors:
error C2039: 'staticMetaObject' : is not a member of 'Interface'
error C2039: 'qt_metacast' : is not a member of 'Interface'
error C2039: 'qt_metacall' : is not a member of 'Interface'
error C3861: 'connect': identifier not found
My .pro file looks like this:
TEMPLATE = lib
CONFIG += qt dll
HEADERS = Interface.h \
Plugin.h
SOURCES = Plugin.cpp
Bookmarks