What's the proper way for the main GUI thread to update a QProgressDialog while waiting for a QFuture. Specifically, what goes in this loop:
QProgressDialog pd(...);
QFuture f = ...;
while (!f.isFinished()) {
pd.setValue(f.progressValue());
// what goes here?
}
Right now I have a sleep() like call there, but that's not optimal (and ofcourse introduces some GUI latency).
If I put nothing, the main thread will loop-pole pd.setValue(), wasting CPU cycles.
I was hoping of putting something like QCoreApplication::processEvents(flags,maxtime), but that returns immediately if the event queue is empty. I'd like a version that waits until maxtime or whatever even if the queue is empty. That way, I get my delay and the main thread is always ready to respond to GUI events.