I want to call a QObject method from a different thread (Qt::QueuedConnection) if my app is multithreaded and from the same thread (Qt::DirectConnection) if my app is running on a single thread.
I found it could be achieved in two way 1)signal/slot 2)QMetaObject::invokeMethod using Qt::AutoConnection, but I would like to know which one is preferred and is there any performance difference between them?
- Signal/slot Qt::AutoConnection:
- QMetaObject::invokeMethod Qt::AutoConnection:
There is already an existing code base which is done with signal/slot way, but it's quite difficult to read. Is it worth refactoring it with QMetaObject::invokeMethod?
function arguments could be a custom type too.