In this tutorial we will see how to run a function asynchronously using QtConcurrent and also use signals and slots to update GUI from the thread created by QtConcurrent. In addition to this, we also have possibility to use signals and slots across the threads. In simpler words, QtConcurrent provides functionality to spawn threads without explicit interaction from the user. 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. In Qt5 we have QThread or QtConcurrent to achieve the same. In C++ we use std::thread or std::async to achieve multi threading. Many a times we need to perform heavy computations using multi threading to distribute this computing load. With computers getting more powerful, data computation is getting expensive.
0 Comments
Leave a Reply. |