
Originally Posted by
midas643
QSignalSpy seems nice. I don't really get capturing local variable by reference.
Something like this:
bool result = false;
auto connectionHandle = connect(sender, &Sender::onFinished, [&result, &l](bool b) { result = b; l.quit(); });
l.exec();
disconnect(connectionHandle);
return result;
bool result = false;
QEventLoop l;
auto connectionHandle = connect(sender, &Sender::onFinished, [&result, &l](bool b) { result = b; l.quit(); });
l.exec();
disconnect(connectionHandle);
return result;
To copy to clipboard, switch view to plain text mode

Originally Posted by
midas643
What's the "job" object? Should I make my own class for that?
Yes, a job would be an object of a class that encapsulates all data and state for an asynchronous operation.
See for example QNetworkReply.

Originally Posted by
midas643
Can I pass the value to exit SLOT using some signal ?
Not directly, QEventLoop::exit() is not a slot.
Of course you can use a slot, function or lambda that gets connected to and which then calls exit.

Originally Posted by
midas643
What are the consequences of nested event loops ?
As I said above: a nested event loop can lead to reentrancy-like situations.
The call appears to be synchronous to a reader but of course it is not.
Other events (user interaction, timers, sockets, etc) can lead to the method being called again, or the object that has this method being destroyed, etc.
Cheers,
_
Bookmarks