QAbstractEventDispatcher Class Reference

[ QtCore module]

The QAbstractEventDispatcher class provides an interface to manage Qt's event queue. 更多...

继承 QObject .

方法

Static Methods

Qt Signals


详细描述

The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.

An event dispatcher receives events from the window system and other sources. It then sends them to the QCoreApplication or QApplication instance for processing and delivery. QAbstractEventDispatcher provides fine-grained control over event delivery.

对于事件处理的简单控制,请使用 QCoreApplication.processEvents ().

为更好地控制应用程序的事件循环,调用 instance () 和调用 functions on the QAbstractEventDispatcher object that is returned. If you want to use your own instance of QAbstractEventDispatcher or of a QAbstractEventDispatcher subclass, you must create your instance before you create the QApplication 对象。

启动 main 事件循环通过调用 QCoreApplication.exec (),和 stopped by calling QCoreApplication.exit (). Local event loops can be created using QEventLoop .

履行长时间操作的程序可以调用 processEvents () with a bitwise OR combination of various QEventLoop.ProcessEventsFlag 值去控制应该交付哪些事件。

QAbstractEventDispatcher also allows the integration of an external event loop with the Qt event loop. For example, the Motif Extension includes a reimplementation of QAbstractEventDispatcher that merges Qt and Motif events together.


方法文档编制

QAbstractEventDispatcher.__init__ ( self , QObject   parent  = None)

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

构造新事件分派程序采用给定 parent .

QAbstractEventDispatcher.closingDown ( self )

bool QAbstractEventDispatcher.filterEvent ( self , sip.voidptr  message )

发送 message through the event filter that was set by setEventFilter (). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter 函数。

Subclasses of QAbstractEventDispatcher must call this function for all messages received from the system to ensure compatibility with any extensions that may be used in the application.

Note that the type of message is platform dependent. See QAbstractEventDispatcher.EventFilter 了解细节。

另请参阅 setEventFilter ().

QAbstractEventDispatcher.flush ( self )

This method is abstract and should be reimplemented in any sub-class.

Flushes the event queue. This normally returns almost immediately. Does nothing on platforms other than X11.

bool QAbstractEventDispatcher.hasPendingEvents ( self )

This method is abstract and should be reimplemented in any sub-class.

Returns true if there is an event waiting; otherwise returns false.

QAbstractEventDispatcher QAbstractEventDispatcher.instance ( QThread   thread  = None)

Returns a pointer to the event dispatcher object for the specified thread 。若 thread is zero, the current thread is used. If no event dispatcher exists for the specified thread, this function returns 0.

注意: If Qt is built without thread support, the thread argument is ignored.

QAbstractEventDispatcher.interrupt ( self )

This method is abstract and should be reimplemented in any sub-class.

Interrupts event dispatching; i.e. the event dispatcher will return from processEvents () as soon as possible.

bool QAbstractEventDispatcher.processEvents ( self , QEventLoop.ProcessEventsFlags   flags )

This method is abstract and should be reimplemented in any sub-class.

处理待决事件匹配 flags until there are no more events to process. Returns true if an event was processed; 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 QEventLoop.ExcludeUserInputEvents 标志。

QEventLoop.WaitForMoreEvents flag is set in flags , the behavior of this function is as follows:

QEventLoop.WaitForMoreEvents flag is not set in flags , and no events are available, this function will return immediately.

注意: This function does not process events continuously; it returns after all available events are processed.

另请参阅 hasPendingEvents ().

list-of-tuple-of-int-int QAbstractEventDispatcher.registeredTimers ( self , QObject   object )

This method is abstract and should be reimplemented in any sub-class.

返回注册计时器列表为 object . The timer ID is the first member in each pair; the interval is the second.

QAbstractEventDispatcher.registerSocketNotifier ( self , QSocketNotifier   notifier )

This method is abstract and should be reimplemented in any sub-class.

注册 notifier with the event loop. Subclasses must implement this method to tie a socket notifier into another event loop.

int QAbstractEventDispatcher.registerTimer ( self , int  interval , QObject   object )

Registers a timer with the specified interval 为 given object .

QAbstractEventDispatcher.registerTimer ( self , int  timerId , int  interval , QObject   object )

This method is abstract and should be reimplemented in any sub-class.

注册计时器采用指定 timerId and interval 为给定 object .

callable QAbstractEventDispatcher.setEventFilter ( self , callable  filter )

filter argument may also be None.

Replaces the event filter function for this QAbstractEventDispatcher with filter and returns the replaced event filter function. Only the current event filter function is called. If you want to use both filter functions, save the replaced EventFilter in a place where yours can call it.

The event filter function set here is called for all messages taken from the system event loop before the event is dispatched to the respective target, including the messages not meant for Qt 对象。

The event filter function should return true if the message should be filtered, (i.e. stopped). It should return false to allow processing the message to continue.

By default, no event filter function is set (i.e., this function returns a null EventFilter the first time it is called).

QAbstractEventDispatcher.startingUp ( self )

QAbstractEventDispatcher.unregisterSocketNotifier ( self , QSocketNotifier   notifier )

This method is abstract and should be reimplemented in any sub-class.

Unregisters notifier from the event dispatcher. Subclasses must reimplement this method to tie a socket notifier into another event loop. Reimplementations must call the base 实现。

bool QAbstractEventDispatcher.unregisterTimer ( self , int  timerId )

This method is abstract and should be reimplemented in any sub-class.

Unregisters the timer with the given timerId 。返回 true if successful; otherwise returns false.

另请参阅 registerTimer () and unregisterTimers ().

bool QAbstractEventDispatcher.unregisterTimers ( self , QObject   object )

This method is abstract and should be reimplemented in any sub-class.

Unregisters all the timers associated with the given object . Returns true if all timers were successful removed; otherwise returns false.

另请参阅 unregisterTimer () and registeredTimers ().

QAbstractEventDispatcher.wakeUp ( self )

This method is abstract and should be reimplemented in any sub-class.

唤醒事件循环。

注意: 此函数是 thread-safe .

另请参阅 awake ().


Qt Signal Documentation

void aboutToBlock ()

This is the default overload of this signal.

This signal is emitted before the event loop calls a function that could block.

另请参阅 awake ().

void awake ()

This is the default overload of this signal.

This signal is emitted after the event loop returns from a function that could block.

另请参阅 wakeUp () 和 aboutToBlock ().