my testcase:
{
Q_OBJECT
public slots:
void foo() {
qDebug() << "foo called";
}
};
int main(int argc, char** argv)
{
test* x = new test;
x->foo(); //works
QTimer::singleShot(0, x,
SLOT(foo
()));
//works QMetaObject::invokeMethod(x,
SLOT(foo
()));
//doesn't work app.exec();
}
#include "main.moc"
class test : public QObject
{
Q_OBJECT
public slots:
void foo() {
qDebug() << "foo called";
}
};
int main(int argc, char** argv)
{
QApplication app(argc,argv);
test* x = new test;
x->foo(); //works
QTimer::singleShot(0, x, SLOT(foo())); //works
QMetaObject::invokeMethod(x, SLOT(foo())); //doesn't work
app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
what's wrong? Why doesn't this work? (invoceMethod returns false - which means that the method is not found)
thanks,
niko
Bookmarks