PDA

View Full Version : Dialogs in plugin files



bhs-ittech
25th January 2007, 13:23
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)


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();
}


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?

jpn
25th January 2007, 13:32
warning: Object::connect: No such slot QDialog::someFunction()

The declaration of UIDialog seems to be missing Q_OBJECT macro.

bhs-ittech
25th January 2007, 13:37
Ups... so it does :o

something so simple and I just missed it.

Many thanks jpn