Thread
We use PySide6's QThread class for multi-threaded operations.
Basic QThread Usage
1. Inheriting QThread Class
2. Defining Signals (Optional)
3. Thread Usage Example
Key Methods and Signals
QThread Basic Methods
start()
: Start threadquit()
: Request thread terminationwait()
: Wait until thread terminatesisRunning()
: Check if thread is runningterminate()
: Force thread termination (not recommended)
Basic Signals
started
: Emitted when thread startsfinished
: Emitted when thread ends
Important Notes
GUI updates should only be performed on the main thread.
Avoid using
terminate()
as it forces termination without resource cleanup.Proper synchronization is needed when sharing data between threads.
Example: Progress Display Operation
This guide explains the basic methods of implementing multi-threading using QThread in PySide6. In actual applications, please design and use appropriate signals and slots according to the characteristics of your tasks.
Last updated