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
3
votes
2 answers

QtConcurrent wait for finished when App is about to quit

I can't find any clear solution to this. I have a thread started with QtConcurrent::run(). When I close the application before the thread is finished, the application crashes. I want the application to close after all backgroud threads…
Kevin yudo
  • 233
  • 4
  • 15
3
votes
2 answers

Packaging a threaded program with Qt GUI

I have a working, finished application which uses multiple boost threads and works fine with a command line interface. I have packaged this program with a "wrapper" class so that I can run the functions within the program from a Qt Main Window. For…
user2290362
  • 717
  • 2
  • 7
  • 21
3
votes
2 answers

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

So I have been using QtConcurrent::run for some time and its fantastic. But now I need the function to return an object. Therefore I use the pseudo code QFutureWatcher fw; QFuture t1 = QtConcurrent::run(&thOb,…
DannyK
  • 267
  • 2
  • 12
3
votes
1 answer

QObject: Cannot create children for a parent that is in a different thread with QtConcurrent::run

I am trying to use thread in qt but I get some strange error in the codes I used. the Function I am using threads. QThreadPool::globalInstance()->setMaxThreadCount(size); QFutureSynchronizer synchronizer; for(quint64 i=0;i
3
votes
2 answers

QtConcurrent.run() with a c++11 lambda that captures a reference to "this" to emit signal

While this works, I have this strange feeling my QObject emit is not threadsafe and the fact that this hasn't exploded yet is just luck. void LoginController::attemptLogin(QString username, QString password) { emit…
David Stocking
  • 1,200
  • 15
  • 26
3
votes
1 answer

Variadic template to proxy QtConcurrent::run functions

I was hoping to create a variadic template function which sits in front of the QtConcurrent::run functions that does some stuff and then passes the parameters on. QtConcurrent::run is massively overloaded - check out qtconcurrentrun.h Is it…
gremwell
  • 1,419
  • 17
  • 23
3
votes
1 answer

std::bind, this and QtConcurrent

Im trying to use std::bind to bind this to method that is used in QtConcurrent::blockingMapped Header: class TuringMachine { private: TRTable table; std::set currentConfigs; //function object …
TeaOverflow
  • 2,468
  • 3
  • 28
  • 40
3
votes
1 answer

QtConcurrent::map() with member function = can not compile

My project is to create a small program which demonstrates the work of a search engine: indexing and returning result for arbitrary queries. I've done the work with the indexer part and now I want to improve it with indexing multiple files at once.…
herophuong
  • 354
  • 6
  • 17
2
votes
2 answers

Threading a function in Qt

I have a for-loop that will run a fixed number of times, usually in the 100-300 range depending on the input. Every iteration of this loop calls a function that I want to be threaded. The function to thread grabs data from an input file, does some…
user869525
  • 769
  • 2
  • 12
  • 21
2
votes
3 answers

How does Qt bind pointers-to-non-static-member-functions in QtConcurrent?

From the QtConcurrent documentation: QByteArray bytearray = "hello world"; QFuture > future = QtConcurrent::run(bytearray, &QByteArray::split), ','); ... QList result = future.result(); The code snippet above appears…
sam-w
  • 7,478
  • 1
  • 47
  • 77
2
votes
1 answer

QtConcurrent::blockingMapped() and std::vector<> bug

It seems that QtConcurrent works fine with QT containers (QList and QVector), but fails with the STL containers, as opposed to what is claimed in the documentation Here are the dummy functions I want to use on my containers : void addOne(int &…
B. Decoster
  • 7,723
  • 1
  • 32
  • 52
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
3 answers

Using QtConcurrent to load a Pixmap and paint it

I'm trying to create a Tile rendering program. Heres some basic code. Header class Tile: public QGraphicsItem { public: Tile(void); ~Tile(void); QGraphicsPixmapItem *tileItem; void update(QPainter *painter, const QStyleOptionGraphicsItem…
sleeping.ninja
  • 607
  • 1
  • 10
  • 21
2
votes
1 answer

Can QtConcurrent::run be used with smart pointers to objects?

Qt Documentation states that QtConcurrent::run can be used to run a member function in another thread by passing the pointer to the object as the first argument. However, I couldn't find any info if smart pointers can be used in this case.…
burzan
  • 23
  • 3
2
votes
1 answer

QObject::killTimer: Timers cannot be stopped from another thread

I have a QGraphicsView in my MainWindow that I created that in my Ui (of course with the base thread) and I want to set a QGraphicsScene on it from another thread. So in constructor of MainWindow I have: MainWindow::MainWindow(QWidget *parent) :…
1 2
3
12 13