mardi 19 août 2014

Blocked QFuture.result() or QFutureWatcher.waitForFinished();


Vote count:

0




So I have been using QtConcurrent::run for some time and its fantastic. But not I need a function to return an object. Therefore I use the pseudo code QFutureWatcher fw; QFuture t1 = QtConcurrent::run(&thOb, &MythreadObjFunc::getList, ConSettings, form, query); fw.setFuture(t1); // Both .results() and waitForFinished() block fw.waitForFinished(); MyObject entries = t1.result();


Then I iterate through the myObject. The issue is that this is blocking e.g. my main GUI is not responsive. And this was the whole reason I started using QtConcurrent::run


Therefore, what is the recommended way to have my GUI execute a QtConcurrent::run and get the object back but not block? I thought of signals and slots where the signal would be from the QtConcurrent::run but this would mean that it would be from a different thread and I read thats not recommended.


Thanks for your time.



asked 1 min ago







Blocked QFuture.result() or QFutureWatcher.waitForFinished();

Aucun commentaire:

Enregistrer un commentaire