In ObjC with GCD, there is a way of executing a lambda in any of the threads that spin an event loop. For example:
dispatch_sync(dispatch_get_main_queue(), ^
Others have exelent answers. here is my suggest. instead of doing something like this:-
QMetaObject::invokeMethod(socketManager,"newSocket",
Qt::QueuedConnection,
Q_ARG(QString, host),
Q_ARG(quint16, port.toUShort()),
Q_ARG(QString, username),
Q_ARG(QString, passhash)
);
do something like this which is more nice:-
QMetaObject::invokeMethod(socketManager,[=](){
socketManager->newSocket(host,port.toUShort(),username,passhash);
},Qt::QueuedConnection);