Questions tagged [qtconcurrent]

QtConcurrent is a Qt framework namespace providing high-level multithreading APIs.

QtConcurrent namespace was introduced in Qt 4.4. The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives such as mutexes, read-write locks, wait conditions, or semaphores.

As of Qt 4.8.0, it includes:

  • 2 Classes
  • 2 Types
  • and mostly Functions

As of Qt 5, it became a separate add-on module, and includes:

  • QtConcurrent namespace
  • QFuture
  • QFutureIterator
  • QFutureWatcher
  • QFutureSynchronizer

Details can be found on the following page.

Resources:

193 questions
2
votes
1 answer

Getting item sequence numbers from a QtConcurrent Threaded Calculation

The QtConcurrent namespace is really great for simplifying the management of multi-threaded calculations. Overall this works great and I have been able to use QtConcurrent run(), map(), and other variants in the way they are described in the…
Bruce Dean
  • 2,798
  • 2
  • 18
  • 30
2
votes
1 answer

Using QMutexLocker to Protect Shared Variables when Running Function with QtConcurrent

I do a discovery process in a background thread by using QtConcurrent: // Start the discover process in the background thread so it doesn't block the gui *m_Future = QtConcurrent::run(this,…
PhilBot
  • 748
  • 18
  • 85
  • 173
2
votes
1 answer

How to map QtConcurrent on a QList of QVector and reduce into one QVector

I really tried to combine everything I know in order to make this work. I believe there will be no problem with deadlock or other thread issues in the current structure. However, some pieces are missing, and the available documentation is not…
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
2
votes
2 answers

QtConcurrent mapped and progress report

I'm using QtConcurrent to do some heavy background image processing and I want to display the image while parts of it are being updated progressively. Each line of the image is computed separately and is passed a functor. To compute the full image…
Lex
  • 413
  • 1
  • 7
  • 19
2
votes
1 answer

QtConcurrent::run() doesn't accept __stdcall/WINAPI function

I was trying to execute a DLL function that has __stdcall calling convention using QtConcurrent::run(), but I am getting compile errors. I've reduced the problem to this example code: __stdcall void dllFunc() { qDebug() << "test"; } void test()…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
2
votes
3 answers

How to offload a computationally heavy task which is highly dependent on proper exception handling?

In my Qt application I have to perform some computationally heavy tasks, typically loading huge datasets from disk (single-threaded). The code in the task heavily relies on proper exception handling and is strictly non-Qt. I offload these tasks from…
c_k
  • 1,746
  • 1
  • 20
  • 35
2
votes
1 answer

Qt terminate thread spawn by QConcurrent::run

Platform: Win7 x64, MinGW-rubenvb (4.7.2-x64), Qt 4.8 Say I have few lengthy tasks (read population file, write population file, and run simulation) spawned using QConcurrent::run, as follow: void MainWindow::runLengthyJob() { /* some setup */ …
YamHon.CHAN
  • 866
  • 4
  • 20
  • 36
2
votes
0 answers

QtConcurrent::run with functor

How to use QtConcurrent::run with function objects? Can you please show me an example how to do that?
nazar554
  • 303
  • 2
  • 7
2
votes
3 answers

Best practice for non-interrupting I/O

I have a small app that I am working with that needs to produce a very verbose log. I have implemented a simple singleton Logger class which looks like this #ifndef LOGGER_H #define LOGGER_H #include #include #include…
JD Guzman
  • 368
  • 2
  • 7
2
votes
0 answers

QtConcurrent with static member function

I successfully parallelized some work with non-static member function in QtConcurrent::run(). I am now trying to implement parallelized work with a static member function. I have a Random class, and I want to call rand(double,double) static function…
kiriloff
  • 25,609
  • 37
  • 148
  • 229
2
votes
0 answers

QFuture throwing unhandled exception in result()

I run 3 parallel threads (plus current thread) in a method to parallelize calls to na optimization method. Code looks like for(i=0;i
kiriloff
  • 25,609
  • 37
  • 148
  • 229
1
vote
0 answers

pass a function to QtConcurrent::map

Here's my desired code: class Machine { private: QSet states; State* step(State* st){/*...*/} public: void makeStep(){ //... QTConcurrent::map(states, step); //... } My problem: This doesn't compile,…
TeaOverflow
  • 2,468
  • 3
  • 28
  • 40
1
vote
2 answers

QtConcurrent blockingMappedReduced error

This is my first attempt at using QtConcurrent::blockingMappedReduced, and I can't get it to build in MSVC 2010 Express (with QT 4.7.1 source code). I have created a small example that is similar to my actual code, and it has the same problem…
user1020872
  • 111
  • 1
  • 9
1
vote
0 answers

how to use signals and slots with QtConcurrent::run and QFutureWatcher

I'm trying to copy files with the progress bar, I have a method that works with QtConcurrent::run but when I connect to progressBar nothing happens but the file is copied successfully. I would like to know what is wrong with my code and how to fix…
Aquiles
  • 13
  • 3
1
vote
1 answer

QtConcurrent error: attempting to reference a deleted function

I'd like to run simple method in a different thread than the GUI thread inside my Qt application. To do this I'm using QFuture and Qt Concurrent. However, I ran into a compile…
mathripper
  • 299
  • 1
  • 12