I want to call arbitrary slot of QObject in other thread.
I have:
| Arguments: | Can use QueuedConnection?
QMetaObject::invokeMethod | fixed number | YES
qt_metacall | array | NO
I want:
<something> | array | YES
I don't want to do things like duplicating invokeMethod code based on the number of arguments.
Where to get invokeMethod that accepts array of arguments or how to make qt_metacall queued?
You can either:
Qt::QueuedConnectionand call the signal withqt_metacalland your array, orQObjectderived class that:QMetaObject::invokeMethodin the constructor withQt::QueuedConnectionto invoke a slot without parameter which will callqt_metacallwith the stored parameter array before deleting theQObject.Internally Qt uses the 2nd method but with a internal class:
QMetaCallEvent(in corelib/kernel/qobject_p.h) andpostEventinstead of a signal/slot connection.