QMetaObject::invokeMethod

Stöger, Berthold berthold.stoeger at tuwien.ac.at
Sat Jul 7 14:14:18 PDT 2018


Hi Robert,

Still abroad, therefore very briefly:

1) At the risk of being pedantic: This has nothing to do with C++, but with Qt/MOC. This wouldn't even work with plain C++. There's a slightly more modern pointer-to-member-function version, but that didn't compile on qt5.5.

2) I use this to call a function across thread boundaries (notably to transport data from a worker thread to the UI thread). For unknown reasons, QNetworkManager and QMediaPlayer refused to work in a non-UI thread.

3) You are right: This could be done just as well by sending a signal from the worker thread-object to a slot in the UI thread-object. In a PR I think Lubomir (sorry, if I mis-attribute) noted that connecting a signal from an object to itself is weird and therefore in this case invokeMethod was preferred. This just stuck, even if in this case it's connecting different objects.

4) I don't have any problems with this being changed to signal/slot, I would just ask to wait until the "Video-lite" PR is in master, so that we don't step on each other's toes.

Berthold


More information about the subsurface mailing list