QRunnable¶
Synopsis¶
Functions¶
def
autoDelete
()def
setAutoDelete
(_autoDelete)
Virtual functions¶
def
run
()
Detailed Description¶
The
QRunnable
class is an interface for representing a task or piece of code that needs to be executed, represented by your reimplementation of therun()
function.You can use
QThreadPool
to execute your code in a separate thread.QThreadPool
deletes theQRunnable
automatically ifautoDelete()
returnstrue
(the default). UsesetAutoDelete()
to change the auto-deletion flag.
QThreadPool
supports executing the sameQRunnable
more than once by callingtryStart
(this) from within therun()
function. IfautoDelete
is enabled theQRunnable
will be deleted when the last thread exits the run function. Callingstart()
multiple times with the sameQRunnable
whenautoDelete
is enabled creates a race condition and is not recommended.See also
- class PySide2.QtCore.QRunnable¶
Constructs a
QRunnable
. Auto-deletion is enabled by default.See also
- PySide2.QtCore.QRunnable.autoDelete()¶
- Return type:
bool
Returns
true
is auto-deletion is enabled; false otherwise.If auto-deletion is enabled,
QThreadPool
will automatically delete this runnable after callingrun()
; otherwise, ownership remains with the application programmer.See also
- PySide2.QtCore.QRunnable.run()¶
Implement this pure virtual function in your subclass.
- PySide2.QtCore.QRunnable.setAutoDelete(_autoDelete)¶
- Parameters:
_autoDelete – bool
Enables auto-deletion if
autoDelete
is true; otherwise auto-deletion is disabled.If auto-deletion is enabled,
QThreadPool
will automatically delete this runnable after callingrun()
; otherwise, ownership remains with the application programmer.Note that this flag must be set before calling
start()
. Calling this function afterstart()
results in undefined behavior.See also
© 2022 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.