内容表

上一话题

QEvent

下一话题

QEventTransition

QEventLoop

QEventLoop class provides a means of entering and leaving an event loop. 更多

Inheritance diagram of PySide2.QtCore.QEventLoop

概要

函数

详细描述

At any time, you can create a QEventLoop object and call exec() on it to start a local event loop. From within the event loop, calling exit() will force exec() to return.

class QEventLoop ( [ parent=None ] )
param parent

QObject

构造事件循环对象采用给定 parent .

PySide2.QtCore.QEventLoop. ProcessEventsFlag

此枚举控制处理事件的类型通过 processEvents() 函数。

常量

描述

QEventLoop.AllEvents

所有事件。注意: DeferredDelete 事件会被特殊处理。见 deleteLater() 了解更多细节。

QEventLoop.ExcludeUserInputEvents

不处理用户输入事件,譬如 ButtonPress 和 KeyPress。注意,事件未被丢弃;会交付他们当下次 processEvents() is called without the flag.

QEventLoop.ExcludeSocketNotifiers

不处理套接字通知事件。注意,事件未被丢弃;会交付他们当下次 processEvents() is called without the flag.

QEventLoop.WaitForMoreEvents

等待事件,若没有待决事件可用。

另请参阅

processEvents()

PySide2.QtCore.QEventLoop. exec_ ( [ flags=QEventLoop.AllEvents ] )
参数

flags ProcessEventsFlags

返回类型

int

进入主事件循环并等待,直到 exit() is called. Returns the value that was passed to exit() .

flags 有指定,仅允许类型的事件通过 flags 会被处理。

有必要调用此函数以启动事件处理。主事件循环从窗口系统接收事件,并将其分派给应用程序 Widget。

Generally speaking, no user interaction can take place before calling . As a special case, modal widgets like QMessageBox can be used before calling , because modal widgets use their own local event loop.

要使应用程序履行空闲处理 (即:执行特殊函数每当没有待决事件时),使用 QTimer 采用 0 超时。可以达成更完备空闲处理方案使用 processEvents() .

PySide2.QtCore.QEventLoop. exit ( [ returnCode=0 ] )
参数

returnCode int

告诉事件循环,采用返回代码退出。

在此函数被调用之后,事件循环返回从调用 exec() exec() function returns returnCode .

按约定, returnCode 0 意味着成功,而任何非零值指示出错。

注意:不像同名 C 库函数,此函数 does return to the caller – it is event processing that stops.

另请参阅

quit() quit() exec()

PySide2.QtCore.QEventLoop. isRunning ( )
返回类型

bool

返回 true 若事件循环正在运行;否则返回 false。认为事件循环开始运行当 exec() is called until exit() 被调用。

另请参阅

exec() exit()

PySide2.QtCore.QEventLoop. processEvents ( [ flags=QEventLoop.AllEvents ] )
参数

flags ProcessEventsFlags

返回类型

bool

处理待决事件匹配 flags 直到没有更多要处理事件为止。返回 true 若待决事件被处理;否则返回 false .

此函数尤其有用,若有长时间运行操作且不允许用户输入想要展示其进度;即:通过使用 ExcludeUserInputEvents 标志。

此函数仅仅是包裹器为 processEvents() . See the documentation for that function for details.

PySide2.QtCore.QEventLoop. processEvents ( flags , maximumTime )
参数
  • flags ProcessEventsFlags

  • maximumTime int

处理待决事件匹配 flags 对于最大 maxTime 毫秒,或直到没有更多要处理事件为止,以较短者为准。此函数尤其有用,若有长时间运行操作且不允许用户输入想要展示其进度,即:通过使用 ExcludeUserInputEvents 标志。

注意事项:

  • 此函数不连续处理事件;它返回在处理所有可用事件之后。

  • 指定 WaitForMoreEvents 标志没有意义且会被忽略。

PySide2.QtCore.QEventLoop. quit ( )

告诉事件循环要正常退出。

如同 exit(0)。

另请参阅

quit() exit()

PySide2.QtCore.QEventLoop. wakeUp ( )

唤醒事件循环。

另请参阅

wakeUp()