内容表

上一话题

QResource

下一话题

QSaveFile

QRunnable

QRunnable class is the base class for all runnable objects. 更多

Inheritance diagram of PySide2.QtCore.QRunnable

概要

函数

虚函数

详细描述

QRunnable class is an interface for representing a task or piece of code that needs to be executed, represented by your reimplementation of the run() 函数。

可以使用 QThreadPool to execute your code in a separate thread. QThreadPool deletes the QRunnable automatically if autoDelete() 返回 true (the default). Use setAutoDelete() to change the auto-deletion flag.

QThreadPool supports executing the same QRunnable 多次通过调用 tryStart (this) from within the run() function. If autoDelete is enabled the QRunnable 将被删除当最后一个线程退出 run 函数时。调用 start() multiple times with the same QRunnable when autoDelete is enabled creates a race condition and is not recommended.

另请参阅

QThreadPool

class QRunnable

构造 QRunnable . Auto-deletion is enabled by default.

PySide2.QtCore.QRunnable. autoDelete ( )
返回类型

bool

返回 true is auto-deletion is enabled; false otherwise.

If auto-deletion is enabled, QThreadPool will automatically delete this runnable after calling run() ; otherwise, ownership remains with the application programmer.

PySide2.QtCore.QRunnable. run ( )

Implement this pure virtual function in your subclass.

PySide2.QtCore.QRunnable. setAutoDelete ( _autoDelete )
参数

_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 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.