PySide6.QtCore.QRunnable¶
- class QRunnable¶
- The - QRunnableclass is the base class for all runnable objects. More…- Synopsis¶- Methods¶- def - __init__()
- def - autoDelete()
- def - setAutoDelete()
 - Virtual methods¶- def - run()
 - Static functions¶- def - create()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- The - QRunnableclass is an interface for representing a task or piece of code that needs to be executed, represented by your reimplementation of the- run()function.- You can use - QThreadPoolto execute your code in a separate thread.- QThreadPooldeletes the- QRunnableautomatically if- autoDelete()returns- true(the default). Use- setAutoDelete()to change the auto-deletion flag.- QThreadPoolsupports executing the same- QRunnablemore than once by calling- tryStart(this) from within the- run()function. If- autoDeleteis enabled the- QRunnablewill be deleted when the last thread exits the run function. Calling- start()multiple times with the same- QRunnablewhen- autoDeleteis enabled creates a race condition and is not recommended.- See also - __init__()¶
 - Constructs a - QRunnable. Auto-deletion is enabled by default.- See also - autoDelete()¶
- Return type:
- bool 
 
 - Returns - trueis auto-deletion is enabled; false otherwise.- If auto-deletion is enabled, - QThreadPoolwill automatically delete this runnable after calling- run(); otherwise, ownership remains with the application programmer.- See also - abstract run()¶
 - Implement this pure virtual function in your subclass. - setAutoDelete(autoDelete)¶
- Parameters:
- autoDelete – bool 
 
 - Enables auto-deletion if - autoDeleteis true; otherwise auto-deletion is disabled.- If auto-deletion is enabled, - QThreadPoolwill automatically delete this runnable after calling- run(); otherwise, ownership remains with the application programmer.- Note that this flag must be set before calling - start(). Calling this function after- start()results in undefined behavior.- See also