The recommended way of working with threads in Qt has changed since the documentation was written. It is usually better not to add signals, let alone slots, to QThread. Instead, create a QObject (derived) instance, and call moveToThread on it to move it to the thread. Put your signals and slots in this worker object instead. Generally it isn't type safe and flexible. There are many problems with them. Qt offer new event-handling system - signal-slot connections. Imagine alarm clock. When alarm is ringing, signal is sending (emitting). And you're handling it as a slot. Every QObject class may have as many signals of slots as you want.
Qt provides thread support in the form of platform-independent threading classes, a thread-safe way of posting events, and signal-slot connections across threads. This makes it easy to develop portable multithreaded Qt applications and take advantage of multiprocessor machines. Multithreaded programming is also a useful paradigm for performing time-consuming operations without freezing the user interface of an application.
Earlier versions of Qt offered an option to build the library without thread support. Since Qt 4.0, threads are always enabled.
Topics:
These articles assume that the reader has basic knowledge about multithreaded applications.
Qt Thread Signal
The Threading Classes
These classes are relevant to threaded applications.
Platform-independent atomic operations on integers |
Template class that provides platform-independent atomic operations on pointers |
Represents the result of an asynchronous computation |
Convenience class that simplifies QFuture synchronization |
Allows monitoring a QFuture using signals and slots |
Access serialization between threads |
Convenience class that simplifies locking and unlocking mutexes |
Convenience class that simplifies locking and unlocking read-write locks for read access |
Read-write locking |
Access serialization between threads |
The base class for all runnable objects |
General counting semaphore |
Exception-safe deferral of a QSemaphore::release() call |
Platform-independent way to manage threads |
Manages a collection of QThreads |
Per-thread data storage |
Condition variable for synchronizing threads |
Convenience class that simplifies locking and unlocking read-write locks for write access |
High-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives |
Java Thread Safe
Note: Qt's threading classes are implemented with native threading APIs; e.g., Win32 and pthreads. Therefore, they can be used with threads of the same native API.
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.