QFuture is a class from the Qt Toolkit which represents the result of an asynchronous computation.
Questions tagged [qfuture]
34 questions
18
votes
5 answers
QFuture that can be cancelled and report progress
The QFuture class has methods such as cancel(), progressValue(), etc. These can apparently be monitored via a QFutureWatcher. However, the documentation for QtConcurrent::run() reads:
Note that the QFuture returned by
QtConcurrent::run() does not…

Dave Mateer
- 17,608
- 15
- 96
- 149
3
votes
1 answer
What happens when QFuture goes out of scope?
I have following code which works (but it should not work)
void myfunction(){
auto future = function_which_return_future();
auto *watcher = new QFutureWatcher;
…

LightSith
- 795
- 12
- 27
3
votes
1 answer
How to create a QFuture with an immediately available value?
I have a function which returns QFuture object as a result of a QtConcurrent::run computation. However, there could be some conditions before running the concurrent method where I need to manually return a value-holding future from my…

John Doe
- 555
- 6
- 17
3
votes
2 answers
QFutureWatcher how to watch multiple tasks/futures and finished() signals
I have some tasks, started with QtConcurrent::run().
Tasks has QFutureWatcher. I know that QFutureWatcher can watch only one Future, but when I started the same tasks from UI, how can I create `QFutureWatcher* on each task? Is it…

Meteo ir3
- 449
- 8
- 21
3
votes
2 answers
QFuture won't work
I am trying to make my application run on multiple threads to make its processes more efficient. I found, on the Qt's website, the QFuture temmplate class that could help me. I am trying to use like in one of their examples. Below is part of my…

Victor
- 13,914
- 19
- 78
- 147
2
votes
1 answer
Use async c++/qt functions in exported python module
I have a dll that is relying extensively on Qt and that exports certain async functions returning QFuture, e.g.
QFuture loadUserAsync();
I want to export such functions (through pybind11) so that customers can write scripts in python. I…

Sc4v
- 348
- 2
- 10
2
votes
1 answer
Qt Program freeze when try to get MD5 of files
Hi im using this code for generate MD5 of files in QT
QString Md5_gen(QString const &s)
{
QString pakchunk_Md5;
QCryptographicHash crypto(QCryptographicHash::Md5);
QFile pakchunk("D:/Games/TDPA - Man of Medan" + s);
if…

sanab3343
- 154
- 1
- 11
2
votes
1 answer
How to design asynchronous wrapper returning values in Qt?
I wrote a wrapper class in Qt for an external executable.
It has plenty of methods, and most of them:
are time-consuming.
need to return the values of different types.
The synchronous wrapper is pretty straight forward in this case:
class…

John Doe
- 555
- 6
- 17
2
votes
1 answer
Free memory using QFuture on cancel thread
I am writing a program that uses QtConcurrent to start threads. In my case, I use it to render a QGraphicsView when I use the mouse scroll.
I am starting the threads using the following code:
if (future.isRunning()) {
future.cancel();
}
future…

Zharios
- 183
- 1
- 18
2
votes
0 answers
Will finished() signal of QFutureWatcher be fired if job completes before it is attached?
Will the finished() signal of QFutureWatcher always be fired, even if the concurrent job that the QFuture represents has completed before the QFutureWatcher is attached to the QFuture?
Consider the following example:
// Start some…

Mr. Developerdude
- 9,118
- 10
- 57
- 95
2
votes
0 answers
QT programming, QtConcurrent run function
I have a program which has class MainWindow that inherited from QMainWindow.
I want to run a specific function in a new thread.
Since I can't inherit from QThread so the best solution is to use QtConcurrent.
I stored QtConcurrent result in a…
user9218823
2
votes
1 answer
Is it possible to use QFuture without QtConcurrent?
I have a program with a QThread, which contains a network client. The client is supposed to take an object, process it, upload it to a server, get the response, and report back to the main thread. I did this with std::promise, and used its future. I…

The Quantum Physicist
- 24,987
- 19
- 103
- 189
1
vote
1 answer
QtConcurrent - keeping GUI responsive amid thousands of results posted to UI thread
I have an application that has potentially long-running tasks and also possibly thousands or millions or results.
This specific application (code below) isn't of any worth, but it is aimed to provide a general use case of the need to maintain a…

CybeX
- 2,060
- 3
- 48
- 115
1
vote
1 answer
How I can close dialog, from another thread? Qt
I want to handle my button in this way:
Change text on label (somethink like "Please wait...")
Download some data from database
When downloading is done, close dialog where is this button.
When I do this:
void…

krecha07
- 31
- 7
1
vote
0 answers
Function not running with QtConcurrent::run() when using QFutureWatcher
I want to call a function to delete files and folders from the system in a parallel thread called by QtConcurrent::run() (Qt for Embedded Linux 4.8). Using only a QFuture with QFuture::waitForFinished() to grab the result (I need to run some…

Momergil
- 2,213
- 5
- 29
- 59