• PySide 模块
  • PySide.QtCore
  • 内容表

    上一话题

    QSystemLocale

    下一话题

    QXmlStreamWriter

    QRunnable

    概要

    函数

    虚函数

    详细描述

    PySide.QtCore.QRunnable class is the base class for all runnable objects.

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

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

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

    class PySide.QtCore. QRunnable

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

    PySide.QtCore.QRunnable. autoDelete ( )
    返回类型: PySide.QtCore.bool

    Returns true is auto-deletion is enabled; false otherwise.

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

    PySide.QtCore.QRunnable. run ( )

    Implement this pure virtual function in your subclass.

    PySide.QtCore.QRunnable. setAutoDelete ( _autoDelete )
    参数: _autoDelete PySide.QtCore.bool

    Enables auto-deletion if autoDelete is true; otherwise auto-deletion is disabled.

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

    Note that this flag must be set before calling QThreadPool.start() . Calling this function after QThreadPool.start() results in undefined behavior.