[Interest] How to clear the result in a QFuture/QFutureWatcher

Calogero Mauceri mauceri at actgate.com
Wed Nov 14 12:04:29 CET 2012

Hi list,

I have a QFuture and QFutureWatcher I'm using to run asynchronously a 
heavy operation.
My QFutureWatcher is a member of my class and every time a new 
computation needs to be done it is initialized with a new QFuture. When 
the QFutureWatcher finishes I read the result.

After I've used the result I'd like to clear the content of the 
QFutureWatcher, but I did not find any method in QFutureWatcher to do 
that. Which is the way to clear the QFutureWatcher result?

This is an example of what I'm doing

class MyClass{
QFutureWatcher<MyRes> myWatcher;


void MyClass::startOp() {
     myWatcher.setFuture( QtConcurrent::run(&heavyOp) );

void MyClass::opFinished(){
     MyRes res = myWatcher.result();


     // how do I clear the result in myWatcher?

Thanks in advance for your help,

Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)

More information about the Interest mailing list