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
0
votes
1 answer

QtConcurrent::mappedReduced without mapped

Consider the following code (Qt 6.0.3, C++17): const QVector arr = {1, 2, 3, 4, 5}; auto future = QtConcurrent::mappedReduced(arr, [](auto item) { return item; }, [](int& result, auto item) { result += item; }); As you can see the…
Roman Podymov
  • 4,168
  • 4
  • 30
  • 57
0
votes
0 answers

QtConcurrent::run as a non static method

I am trying to run a QtConcurrent::run from a QAbstractTableModel but run it as a non static method. Here is my header file: #ifndef DATA_INFO_HPP #define DATA_INFO_HPP #include #include #include…
Styx
  • 1
  • 1
0
votes
2 answers

using QT Process or threads to run functions?

I wanted to run few functions using different threads or QProcess or something which is more effective and also provide good performance. I am trying to build one gui for calibrator and as soon as I press calibrate button it needs to calibrate. For…
user12071441
  • 95
  • 1
  • 8
0
votes
0 answers

QtConcurrent::run stops working after couple of hours

I experienced a strange problem using QtConcurrent::run (Qt 5.8.9). I am using this in a long-running application (a small web server application). QtConcurrent::run is used in several locations in the application and is normally working just…
0
votes
0 answers

Apply multiple functions successively with QtConcurrent::mapped

I want to call multiple functions on the elements of a list with QtConcurrent::mapped. How can I do that? One way would be to to create a composite function and pass that to mapped. However I imagine that might have some drawbacks if the individual…
jdm
  • 9,470
  • 12
  • 58
  • 110
0
votes
1 answer

QtConcurrent mapped with index

I wondered if there is an option to also hand over the current processed index with QtConcurrent::mapped(someVector, &someFunction)) (also filter, filtered, map,...) What I want: I want to do something with the elements in someVector based on the…
schlenger
  • 1,447
  • 1
  • 19
  • 40
0
votes
0 answers

Use QtConcurrent but main thread freeze in Qt

There are thousands of images that want to make thumbnails and load them in list widget. I use QtConcurrent to do it in a separate thread but the problem is that the main thread be freeze while they are loaded. Here is my new thread: void…
0
votes
0 answers

Qt dynamically add tasks to a threadpool queue with pause/stop functionality

Context I have a long running process returning a result. This result may need further processing. There can also be multiple results ready simultaneously. Each one of these results that needs further processing may take a while too. I need to take…
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
2 answers

Multiple QtConcurrent::map execution order

Lets say I have a vector of 100 elements and Func1 and Func2. In the single threaded version Func1 process vector elements and when Func1 finishes, Func2 must start a different process on elements. I'm curious to know if I utilize QtConcurrent::map…
0
votes
1 answer

Using QtConcurrent::map() function on QList yields segmentation fault

I am familiarizing myself with QtConcurrent library. I have a UI (MainWindow) where I run my functions to simulate a real world example of multithreading. The QtConcurrent::map() function I am using requires some: Iterator or a Sequence, in my…
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
0 answers

why QFuture::isFinished() ends early?

I have a question, I am trying to find the most simple way (without eventloop and or QFutureWatcher) to run a function in a different thread without blocking the gui. I have an exporter object from other library, can not change it, and its Close()…
Richy
  • 534
  • 4
  • 13
0
votes
1 answer

Doesn't change value on reference

I'll try run few QtConcurrent, on function which must change value: void MyClass::parse_data_request(QVector &event_vec, QString list_events, QString num, QStringList &loc_key_collector, QStringList &loc_key_ru) And run throw…
0
votes
1 answer

How to cancel QSqldatabase::open immediately in a running thread?

I have a Thread, which opens a database and emits a signal. The main idea is to check if the database is still there and valid. If the database is offline (MYSQL), QSqldatabase is trying for about 3 seconds to connect. Now the problem: If I want to…
ratloser
  • 116
  • 1
  • 7
0
votes
1 answer

Handle multiple Qtcp connections concurrently to show on marble widget

I have an application with qt creator that gets geocoordinate data and shows it on the map.it works fine with just one connection but when it comes to having more than once makes it a riddle. I want to get data in a loop from several qtcp…
0
votes
1 answer

How to replace Qthread with QtConcurrent

I have a SQL fetching class that connects to SQL and fetched the required data. I wanted to this in another thread so I did that with QThread. It is working as it should be. But now I want to replace it with QTConcurrent. The problem I face with…
Mandeep
  • 335
  • 3
  • 13