Originally Posted by
aamer4yu
So this is like calling doSomething in the next event loop, rather than calling it immediately.
So is the other call... The technical difference is the order of calls. Timers are checked after all events are processed, so if you have such code:
Q_OBJECT
public slots:
void funcA() { qDebug() << Q_FUNC_INFO; }
void funcB() { qDebug() << Q_FUNC_INFO; }
};
class Object : public QObject {
Q_OBJECT
public slots:
void funcA() { qDebug() << Q_FUNC_INFO; }
void funcB() { qDebug() << Q_FUNC_INFO; }
};
To copy to clipboard, switch view to plain text mode
and you do this:
Object *o = new Object;
QMetaObject::invokeMethod(o,
"funcA", Qt
::QueuedConnection);
QMetaObject::invokeMethod(o,
"funcB", Qt
::QueuedConnection);
Object *o = new Object;
QMetaObject::invokeMethod(o, "funcA", Qt::QueuedConnection);
QMetaObject::invokeMethod(o, "funcB", Qt::QueuedConnection);
To copy to clipboard, switch view to plain text mode
Then you should get:
- Object::funcA()
- Object::funcB()
But if you do:
Object *o = new Object;
QTimer::singleShot(0, o,
SLOT(funcA
()));
QMetaObject::invokeMethod(o,
"funcB", Qt
::QueuedConnection);
Object *o = new Object;
QTimer::singleShot(0, o, SLOT(funcA()));
QMetaObject::invokeMethod(o, "funcB", Qt::QueuedConnection);
To copy to clipboard, switch view to plain text mode
you will probably get:
- Object::funcB()
- Object::funcA()
I haven't verified that but that's what I would be expecting to see.
Bookmarks