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
1
vote
0 answers

Build fails sample Qt5 Unresolved symbol QtConcurrent QunhandledExecption

trying this sample code qt-concurrent, I am getting LNK2001 unresolved symbol QFutureInterfaceBase on link for x64 arch using MSVC 2019 LNK2001 symbole externe non résolu "__declspec(dllimport) public: void __cdecl…
1
vote
1 answer

Is it possible to subclass QThreadPool for distributed processing?

QtConcurrent is extremely convenient as a high-level interface for multithreaded processing in my data-heavy/CPU-heavy application. The Qt6 upgrades vaguely referenced "Revamped Concurrency APIs" but I didn't see much change, except a reference to…
Phlucious
  • 3,704
  • 28
  • 61
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

Temporarily disable window during a function call

Consider: class Worker { public: void DoWork(); }; class MainWindow : public QMainWindow { Q_OBJECT private: Worker MyWorker; public: void DoWork(); }; I want the DoWork function of my MainWindow to behave like: void…
Pilar Latiesa
  • 675
  • 4
  • 10
1
vote
1 answer

How to close the programme when running a qtconcurrent from another thread in qt

I am running a programme that has multithreading . The programme firstly has a main / UI thread running in it. In this programme I have a worker and handler class. The worker class is having a simulate function which simply generates the random…
Mandeep
  • 335
  • 3
  • 13
1
vote
1 answer

How to use QtConcurrent::mappedReduced with lambdas or std::functions of lambdas?

I'd like to use Qt's mappedReduced with lambdas. Answers to Make QtConcurrent::mapped work with lambdas seem to suggest that this is not possible directly, but might be achieved by use of std::function. But while I can build a compiler-accepted call…
kaba
  • 362
  • 1
  • 13
1
vote
2 answers

Qtconcurrent - Easy way to start a second thread from gui thread

I would like to find an easy way to start a lengthy operation from my application's main gui thread. I have his exporter object that is not affiliated to any thread. void closeExporter() { // Run closing of object in a different thread: …
Richy
  • 534
  • 4
  • 13
1
vote
1 answer

Qt Concurrent with signals & slots

I'm a novice in threads and someone advises me to use Qt Concurrent (Qt C++). I'm trying to run a function in a thread by using Qt Concurrent, my functions runs well but my signal/slot is never emitted. However for your information if I launch my…
1
vote
0 answers

Sleep inside QTConcurrent run method

I'm using QtConcurrent::run to execute some functions in background and not hang the GUI thread. In one function, I read logs from local SQlite database and send them to server by TCP socket. Now I want to delay the execution after each log so the…
DangeMask
  • 531
  • 4
  • 19
1
vote
2 answers

QMutex: destroying locked mutex

Given the following code: #include #include #include #include #include #include #include #include #include #include class…
canellas
  • 491
  • 5
  • 17
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
1 answer

QtConcurrent::map segmentation fault

When I have been trying to implement "parallel for" using QtConcurrent::map: QFuture parForAsync(size_t n, std::function Op) { size_t nThreads = …
Alex Chudinov
  • 654
  • 1
  • 6
  • 12
1
vote
0 answers

QtConcurrent load big file in separate thread and show progress

I need to load a big file which is an .zip archive and contains two files: config and data. The loading progress consists of three stages: parse config, parse data, map data to more appropriate format. I need to do it in a separate thread. Also I…
Divano
  • 583
  • 5
  • 12
1
vote
1 answer

Can not write to QTcpSocket inside QRunnable

I built a server in Qt that takes every client that connects to it and sends the connection away to worker thread (I implement this with QRunnable and I connect the thread to QThreadPool). In my thread I read without a problem from the socket…
YOKO
  • 119
  • 1
  • 7
1
vote
1 answer

Getting data out QFutureWatcher

I am trying to connect my Qt application to a database. Since I have a GUI, of course the only way to do this is in a separate thread. I found out that I can do it via QtConcurrent::run. Here is my code: MainWindow::MainWindow(QWidget *parent) { …
Victor
  • 13,914
  • 19
  • 78
  • 147