PDA

View Full Version : Using QMetaObject::invokeMethod() doesn't work



bruccutler
21st February 2007, 18:30
I'm trying to make my first QMetaObject::invokeMethod() call, but it doesn't work.

Here is what I'm doing:



int main(int argc, char *argv[])
{
QApplication app(argc, argv);

MainProcess *p = new MainProcess();
p->slotStart();
bool bValue = QMetaObject::invokeMethod(p, "slotStart", Qt::DirectConnection); // QueuedConnection);

return app.exec();
}

The p->slotStart() calls the method just fine, but the invokeMethod() returns false.

Any ideas?
- BRC

camel
21st February 2007, 18:41
Any ideas?


Let's start with the simple ones:

slotStart is actually a slot?
MainProcess is a QObject?
MainProcess contains the Q_OBJECT macro?


If you can answer all these questions with yes, we might have to digg deeper ;-)

bruccutler
21st February 2007, 22:40
No - slotStart was not a slot. I had forgotten to include Q_OBJECT in the header file. Oops - I've done that too many times when I create a new class.

Thanks for your help.
- BRC