Okay this problem is some what complex but anyhow;
I have a plugin which have the following definition:
(each class has its own file)
class UIDialog
: public QDialog,
private Ui
::Dialog{
public:
UIDialog() {
setupUi(this);
connect(pushButton, SIGNAL(clicked), this, SLOT(someFunction()));
};
public slots:
void someFunction() {
accept();
};
}
class Interface
{
public:
~Interface() {};
void function1()=0;
};
Q_DECLARE_INTERFACE(Interface,"dk.bhsribe.test/1.0")
class InterfaceImpl
: public QObject,
public Interface
{
Q_OBJECT
Q_INTERFACES(Interface)
public:
void function1() {
UIDialog *win = new UIDialog()
win->exec();
delete win;
};
};
Q_EXPORT_PLUGIN2(inter_imlp,InterfaceImpl)
class UIDialog : public QDialog, private Ui::Dialog
{
public:
UIDialog() {
setupUi(this);
connect(pushButton, SIGNAL(clicked), this, SLOT(someFunction()));
};
public slots:
void someFunction() {
accept();
};
}
class Interface
{
public:
~Interface() {};
void function1()=0;
};
Q_DECLARE_INTERFACE(Interface,"dk.bhsribe.test/1.0")
class InterfaceImpl : public QObject, public Interface
{
Q_OBJECT
Q_INTERFACES(Interface)
public:
void function1() {
UIDialog *win = new UIDialog()
win->exec();
delete win;
};
};
Q_EXPORT_PLUGIN2(inter_imlp,InterfaceImpl)
To copy to clipboard, switch view to plain text mode
and from the main binary the plugin is loaded and a pointer to an instance of Interface
is returned like this:
void Dlg::loadPlugin(int i) {
QPluginLoader loader
(FNamePlug
[i
]);
// FNamePlug is a QVector<QString>which holds // all valid plugin filenames
curInter = qobject_cast<Interface *>(loader.instance());
}
void Dlg::runPlugin() {
curInter->function1();
}
void Dlg::loadPlugin(int i) {
QPluginLoader loader(FNamePlug[i]); // FNamePlug is a QVector<QString>which holds
// all valid plugin filenames
curInter = qobject_cast<Interface *>(loader.instance());
}
void Dlg::runPlugin() {
curInter->function1();
}
To copy to clipboard, switch view to plain text mode
the designed dialog is dislpayed as designed however when I do display the dialog the
debug tells me:
warning: Object::connect: No such slot QDialog::someFunction()
and the intended action for the pushButton can not be called when I click the button.
Why does Qt think that it is QDialog::someFunction() insted of UIDialog::someFunction()
I wish to connect the pushbuttons clicked signal to?
Bookmarks