QEventLoop Class Reference

[ QtCore module]

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

继承 QObject .

类型

方法


详细描述

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

可以随时创建 QEventLoop 对象并调用 exec_ () on it to start a local event loop. From within the event loop, calling exit () 将强制 exec_ () 去返回。


类型文档编制

QEventLoop.ProcessEventsFlag

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

常量 描述
QEventLoop.AllEvents 0x00 所有事件。注意: DeferredDelete events are processed specially. See QObject.deleteLater () for more details.
QEventLoop.ExcludeUserInputEvents 0x01 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 ExcludeUserInputEvents flag.
QEventLoop.ExcludeSocketNotifiers 0x02 Do not process socket notifier events. Note that the events are not discarded; they will be delivered the next time processEvents () 是 called without the ExcludeSocketNotifiers flag.
QEventLoop.WaitForMoreEvents 0x04 Wait for events if no pending events are available.
QEventLoop.DeferredDeletion 0x10 deprecated - do not use.

ProcessEventsFlags 类型是 typedef 对于 QFlags <ProcessEventsFlag>. It stores an OR combination of ProcessEventsFlag values.

另请参阅 processEvents ().


方法文档编制

QEventLoop.__init__ ( self , QObject   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

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

int QEventLoop.exec_ ( self , ProcessEventsFlags   flags  = QEventLoop.AllEvents)

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

flags are specified, only events of the types allowed by the flags 会被处理。

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 exec(). As a special case, modal widgets like QMessageBox can be used before calling exec(), 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 using processEvents ().

另请参阅 QApplication.quit (), exit (),和 processEvents ().

QEventLoop.exit ( self , int  returnCode  = 0)

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

After this function has been called, the event loop returns from the call to exec_ ()。 exec_ () 函数返回 returnCode .

按约定, 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.

另请参阅 QCoreApplication.quit (), quit (),和 exec_ ().

bool QEventLoop.isRunning ( self )

Returns true if the event loop is running; otherwise returns false. The event loop is considered running from the time when exec_ () 被调用直到 exit () 被调用。

另请参阅 exec_ () 和 exit ().

bool QEventLoop.processEvents ( self , ProcessEventsFlags   flags  = QEventLoop.AllEvents)

处理待决事件匹配 flags until there are no more events to process. Returns true if pending events were handled; otherwise returns false.

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 标志。

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

QEventLoop.processEvents ( self , ProcessEventsFlags   flags , int  maximumTime )

处理待决事件匹配 flags 对于最大 maxTime 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 the ExcludeUserInputEvents 标志。

注意事项:

QEventLoop.quit ( self )

This method is also a Qt slot with the C++ signature void quit() .

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

如同 exit(0)。

另请参阅 QCoreApplication.quit () 和 exit ().

QEventLoop.wakeUp ( self )

唤醒事件循环。

另请参阅 QAbstractEventDispatcher.wakeUp ().