QEventLoopclass provides a means of entering and leaving an event loop. 更多 …
def
exec_
([flags=QEventLoop.AllEvents])
def
exit
([returnCode=0])
def
isRunning
()
def
processEvents
([flags=QEventLoop.AllEvents])
def
processEvents
(flags, maximumTime)
def
wakeUp
()
At any time, you can create a
QEventLoopobject and callexec()on it to start a local event loop. From within the event loop, callingexit()will forceexec()to return.
PySide2.QtCore.QEventLoop.
ProcessEventsFlag
¶
此枚举控制处理事件的类型通过
processEvents()
函数。
|
常量 |
描述 |
|---|---|
|
QEventLoop.AllEvents |
所有事件。注意:
|
|
QEventLoop.ExcludeUserInputEvents |
不处理用户输入事件,譬如 ButtonPress 和 KeyPress。注意,事件未被丢弃;会交付他们当下次
|
|
QEventLoop.ExcludeSocketNotifiers |
不处理套接字通知事件。注意,事件未被丢弃;会交付他们当下次
|
|
QEventLoop.WaitForMoreEvents |
等待事件,若没有待决事件可用。 |
另请参阅
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.
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)。