QAbstractEventDispatcherclass provides an interface to manage Qt’s event queue. 更多 …
def
filterNativeEvent
(eventType, message, result)
def
installNativeEventFilter
(filterObj)
def
registerTimer
(interval, timerType, object)
def
removeNativeEventFilter
(filterObj)
def
closingDown
()
def
flush
()
def
hasPendingEvents
()
def
interrupt
()
def
processEvents
(flags)
def
registerSocketNotifier
(notifier)
def
registerTimer
(timerId, interval, timerType, object)
def
registeredTimers
(object)
def
remainingTime
(timerId)
def
startingUp
()
def
unregisterSocketNotifier
(notifier)
def
unregisterTimer
(timerId)
def
unregisterTimers
(object)
def
wakeUp
()
def
aboutToBlock
()
def
awake
()
事件分派程序从窗口系统和其他源接收事件。然后把它们发送给
QCoreApplicationorQApplicationinstance for processing and delivery.QAbstractEventDispatcherprovides fine-grained control over event delivery.对于事件处理的简单控制,请使用
processEvents().For finer control of the application’s event loop, call
instance()and call functions on theQAbstractEventDispatcherobject that is returned. If you want to use your own instance ofQAbstractEventDispatcheror of aQAbstractEventDispatchersubclass, you must install it withsetEventDispatcher()orsetEventDispatcher()before 已安装默认事件分派程序。启动 main 事件循环通过调用
exec(), and stopped by callingexit(). Local event loops can be created usingQEventLoop.履行长时间操作的程序可以调用
processEvents()with a bitwise OR combination of variousProcessEventsFlag值去控制应该交付哪些事件。
QAbstractEventDispatcheralso allows the integration of an external event loop with the Qt event loop.
PySide2.QtCore.QAbstractEventDispatcher.
aboutToBlock
(
)
¶
PySide2.QtCore.QAbstractEventDispatcher.
awake
(
)
¶
PySide2.QtCore.QAbstractEventDispatcher.
closingDown
(
)
¶
PySide2.QtCore.QAbstractEventDispatcher.
filterNativeEvent
(
eventType
,
message
,
result
)
¶
eventType
–
QByteArray
message
–
void
result
–
long
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.
另请参阅
PySide2.QtCore.QAbstractEventDispatcher.
instance
(
[
thread=None
]
)
¶
thread
–
QThread
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
.