内容表

上一话题

QAbstractAnimation

下一话题

QAbstractItemModel

QAbstractEventDispatcher

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

Inheritance diagram of PySide2.QtCore.QAbstractEventDispatcher

概要

函数

虚函数

信号

静态函数

详细描述

事件分派程序从窗口系统和其他源接收事件。然后把它们发送给 QCoreApplication or QApplication instance for processing and delivery. QAbstractEventDispatcher provides fine-grained control over event delivery.

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

For finer control of the application’s event loop, call instance() and call 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 install it with setEventDispatcher() or setEventDispatcher() before 已安装默认事件分派程序。

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

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

QAbstractEventDispatcher also allows the integration of an external event loop with the Qt event loop.

class QAbstractEventDispatcher ( [ parent=None ] )
param parent

QObject

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

PySide2.QtCore.QAbstractEventDispatcher. aboutToBlock ( )
PySide2.QtCore.QAbstractEventDispatcher. awake ( )
PySide2.QtCore.QAbstractEventDispatcher. closingDown ( )
PySide2.QtCore.QAbstractEventDispatcher. filterNativeEvent ( eventType , message , result )
参数
返回类型

bool

发送 message 透过事件过滤器,设置通过 installNativeEventFilter() . This function returns true as soon as an event filter returns true , and false otherwise to indicate that the processing of the event should continue.

子类化的 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. The type of event eventType is specific to the platform plugin chosen at run-time, and can be used to cast message to the right type. The result pointer is only used on Windows, and corresponds to the LRESULT pointer.

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

PySide2.QtCore.QAbstractEventDispatcher. flush ( )

Depending from the event dispatcher implementation does nothing or calls sendPostedEvents() .

PySide2.QtCore.QAbstractEventDispatcher. hasPendingEvents ( )
返回类型

bool

返回 true if there is an event waiting; otherwise returns false. This function is an implementation detail for hasPendingEvents() and must not be called directly.

PySide2.QtCore.QAbstractEventDispatcher. installNativeEventFilter ( filterObj )
参数

filterObj QAbstractNativeEventFilter

安装事件过滤器 filterObj 对于应用程序收到的所有本机事件。

事件过滤器 filterObj 接收事件凭借其 nativeEventFilter() function, which is called for all events received by all threads.

nativeEventFilter() function should return true if the event should be filtered, (in this case, stopped). It should return false to allow normal Qt processing to continue: the native event can then be translated into a QEvent and handled by the standard Qt event filtering, e.g. installEventFilter() .

If multiple event filters are installed, the filter that was installed last is activated first.

注意

The filter function set here receives native messages, that is, MSG or XEvent structs.

For maximum portability, you should always try to use QEvent objects and installEventFilter() whenever possible.

static PySide2.QtCore.QAbstractEventDispatcher. instance ( [ thread=None ] )
参数

thread QThread

返回类型

QAbstractEventDispatcher

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

注意

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

PySide2.QtCore.QAbstractEventDispatcher. interrupt ( )

Interrupts event dispatching. The event dispatcher will return from processEvents() as soon as possible.

PySide2.QtCore.QAbstractEventDispatcher. processEvents ( flags )
参数

flags ProcessEventsFlags

返回类型

bool

处理待决事件匹配 flags 直到没有更多要处理事件为止。返回 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 by using the ExcludeUserInputEvents 标志。

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

  • If events are available, this function returns after processing them.

  • If no events are available, this function will wait until more are available and return after processing newly available events.

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

注意

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

PySide2.QtCore.QAbstractEventDispatcher. registerSocketNotifier ( notifier )
参数

notifier QSocketNotifier

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

PySide2.QtCore.QAbstractEventDispatcher. registerTimer ( interval , timerType , object )
参数
  • interval int

  • timerType TimerType

  • object QObject

返回类型

int

Registers a timer with the specified interval and timerType 为给定 object and returns the timer id.

PySide2.QtCore.QAbstractEventDispatcher. registerTimer ( timerId , interval , timerType , object )
参数
  • timerId int

  • interval int

  • timerType TimerType

  • object QObject

注册计时器采用指定 timerId , interval ,和 timerType 为给定 object .

PySide2.QtCore.QAbstractEventDispatcher. registeredTimers ( object )
参数

object QObject

返回类型

返回注册计时器列表为 object TimerInfo 结构拥有 timerId , interval ,和 timerType 成员。

另请参阅

TimerType

PySide2.QtCore.QAbstractEventDispatcher. remainingTime ( timerId )
参数

timerId int

返回类型

int

Returns the remaining time in milliseconds with the given timerId . If the timer is inactive, the returned value will be -1. If the timer is overdue, the returned value will be 0.

另请参阅

TimerType

PySide2.QtCore.QAbstractEventDispatcher. removeNativeEventFilter ( filterObj )
参数

filterObj QAbstractNativeEventFilter

Removes the event filter filter from this object. The request is ignored if such an event filter has not been installed.

All event filters for this object are automatically removed when this object is destroyed.

It is always safe to remove an event filter, even during event filter filter activation (that is, even from within the nativeEventFilter() 函数)。

PySide2.QtCore.QAbstractEventDispatcher. startingUp ( )
PySide2.QtCore.QAbstractEventDispatcher. unregisterSocketNotifier ( notifier )
参数

notifier QSocketNotifier

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 implementation.

PySide2.QtCore.QAbstractEventDispatcher. unregisterTimer ( timerId )
参数

timerId int

返回类型

bool

Unregisters the timer with the given timerId 。返回 true 若成功;否则返回 false .

PySide2.QtCore.QAbstractEventDispatcher. unregisterTimers ( object )
参数

object QObject

返回类型

bool

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

PySide2.QtCore.QAbstractEventDispatcher. wakeUp ( )

唤醒事件循环。

另请参阅

awake()