The class QEventLoop solved the problem, thanks Client can subclass QEventLoop, and QEventLoop has also an exec() function, so it is still possible to have the Client.exec() in main.