PDA

View Full Version : QProgressDialog updating with QtConcurrent::run() and QFutureWatcher



teb
20th August 2010, 23:23
How do you modify examples/qtconcurrent/progressdialog/main.cpp to use QtConcurrent::run(...) with one threading function that knows the range and can send periodic updates?

One working thread would be a more common thing to give an example for rather than the vector given to QtConcurrent::map(...) which then handles progress updating automatically.

Thanks,
Ted

franz
23rd August 2010, 06:20
QtConcurrent::run() does not support progress information (nor does it support canceling or pausing). You will have to make target function report progress somehow.

The idea of this example and QtConcurrent is that you do not have to worry about how many threads are used, how the synchronization is done and other threading issues. QtConcurrent::run() is more of a convenience function.

teb
23rd August 2010, 16:41
I realize that the example mentioned shows how to handle many threads, but I'm curious about the best Qt way of doing a single thread with progress and a cancel polling check from the worker thread.

QtConcurrent::run()/QFuture appears to almost but not-quite have everything there but if it is not the Qt method for such a basic task, what in general is the best Qt way of doing a worker thread with progress and cancellation?