QEventLoop¶
The
QEventLoop
class provides a means of entering and leaving an event loop. More…
Synopsis¶
Functions¶
def
exec_
([flags=QEventLoop.AllEvents])def
exit
([returnCode=0])def
isRunning
()def
processEvents
([flags=QEventLoop.AllEvents])def
processEvents
(flags, maximumTime)def
wakeUp
()
Slots¶
def
quit
()
Detailed Description¶
At any time, you can create a
QEventLoop
object and callexec()
on it to start a local event loop. From within the event loop, callingexit()
will forceexec()
to return.See also
- class PySide2.QtCore.QEventLoop([parent=None])¶
- param parent:
Constructs an event loop object with the given
parent
.
- PySide2.QtCore.QEventLoop.ProcessEventsFlag¶
This enum controls the types of events processed by the
processEvents()
functions.Constant
Description
QEventLoop.AllEvents
All events. Note that
DeferredDelete
events are processed specially. SeedeleteLater()
for more details.QEventLoop.ExcludeUserInputEvents
Do not process user input events, such as ButtonPress and KeyPress. Note that the events are not discarded; they will be delivered the next time
processEvents()
is called without the flag.QEventLoop.ExcludeSocketNotifiers
Do not process socket notifier events. Note that the events are not discarded; they will be delivered the next time
processEvents()
is called without the flag.QEventLoop.WaitForMoreEvents
Wait for events if no pending events are available.
See also
- PySide2.QtCore.QEventLoop.exec_([flags=QEventLoop.AllEvents])¶
- Parameters:
flags –
ProcessEventsFlags
- Return type:
int
Enters the main event loop and waits until
exit()
is called. Returns the value that was passed toexit()
.If
flags
are specified, only events of the types allowed by theflags
will be processed.It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.
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.To make your application perform idle processing (i.e. executing a special function whenever there are no pending events), use a
QTimer
with 0 timeout. More sophisticated idle processing schemes can be achieved usingprocessEvents()
.See also
- PySide2.QtCore.QEventLoop.exit([returnCode=0])¶
- Parameters:
returnCode – int
Tells the event loop to exit with a return code.
After this function has been called, the event loop returns from the call to
exec()
. Theexec()
function returnsreturnCode
.By convention, a
returnCode
of 0 means success, and any non-zero value indicates an error.Note that unlike the C library function of the same name, this function does return to the caller – it is event processing that stops.
- PySide2.QtCore.QEventLoop.isRunning()¶
- Return type:
bool
Returns
true
if the event loop is running; otherwise returns false. The event loop is considered running from the time whenexec()
is called untilexit()
is called.See also
exec()
exit()
- PySide2.QtCore.QEventLoop.processEvents([flags=QEventLoop.AllEvents])¶
- Parameters:
flags –
ProcessEventsFlags
- Return type:
bool
Processes some pending events that match
flags
. Returnstrue
if pending events were handled; otherwise returnsfalse
.This function is especially useful if you have a long running operation and want to show its progress without allowing user input; i.e. by using the
ExcludeUserInputEvents
flag.This function is simply a wrapper for
processEvents()
. See the documentation for that function for details.
- PySide2.QtCore.QEventLoop.processEvents(flags, maximumTime)
- Parameters:
flags –
ProcessEventsFlags
maximumTime – int
Process pending events that match
flags
for a maximum ofmaxTime
milliseconds, or until there are no more events to process, whichever is shorter. This function is especially useful if you have a long running operation and want to show its progress without allowing user input, i.e. by using theExcludeUserInputEvents
flag.Notes:
This function does not process events continuously; it returns after all available events are processed.
Specifying the
WaitForMoreEvents
flag makes no sense and will be ignored.
- PySide2.QtCore.QEventLoop.quit()¶
Tells the event loop to exit normally.
Same as exit(0).
© 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.