继承者: QChildEvent , QDynamicPropertyChangeEvent , QTimerEvent , QStateMachine.SignalEvent , QStateMachine.WrappedEvent , QActionEvent , QCloseEvent , QContextMenuEvent , QDragEnterEvent , QDragLeaveEvent , QDragMoveEvent , QDropEvent , QEnterEvent , QExposeEvent , QFileOpenEvent , QFocusEvent , QHelpEvent , QHideEvent , QHoverEvent , QIconDragEvent , QInputEvent , QInputMethodEvent , QInputMethodQueryEvent , QKeyEvent , QMouseEvent , QMoveEvent , QNativeGestureEvent , QPaintEvent , QResizeEvent , QScrollEvent , QScrollPrepareEvent , QShortcutEvent , QShowEvent , QStatusTipEvent , QTabletEvent , QToolBarChangeEvent , QTouchEvent , QWhatsThisClickedEvent , QWheelEvent , QWindowStateChangeEvent , QGestureEvent , QGraphicsSceneContextMenuEvent , QGraphicsSceneDragDropEvent , QGraphicsSceneEvent , QGraphicsSceneHelpEvent , QGraphicsSceneHoverEvent , QGraphicsSceneMouseEvent , QGraphicsSceneMoveEvent , QGraphicsSceneResizeEvent , QGraphicsSceneWheelEvent
def
accept
()
def
ignore
()
def
isAccepted
()
def
setAccepted
(accepted)
def
spontaneous
()
def
type
()
def
registerEventType
([hint=-1])
Qt’s main event loop (
exec()) fetches native window system events from the event queue, translates them into QEvents, and sends the translated events toQObjects.通常,事件来自底层窗口系统 (
spontaneous()返回true),但也可能手动发送事件使用sendEvent()andpostEvent()(spontaneous()返回false).
QObjects接收事件通过让其event()function called. The function can be reimplemented in subclasses to customize event handling and add additional event types;event()is a notable example. By default, events are dispatched to event handlers liketimerEvent()andmouseMoveEvent().installEventFilter()allows an object to intercept events destined for another object.The basic
QEventcontains only an event type parameter and an “accept” flag. The accept flag set withaccept(), and cleared withignore(). It is set by default, but don’t rely on this as subclasses may choose to clear it in their constructor.子类化的
QEventcontain additional parameters that describe the particular event.
QEvent
(
type
)
¶
QEvent(other)
- param type
Type- param other
构造事件对象,根据类型
type
.
构造事件对象,根据类型
type
.
PySide2.QtCore.QEvent.
Type
¶
此枚举类型定义 Qt 中的有效事件类型。事件类型和用于每个类型的专用类如下:
|
常量 |
描述 |
|---|---|
|
QEvent.None |
不是事件。 |
|
QEvent.ActionAdded |
新的动作已被添加 (
|
|
QEvent.ActionChanged |
动作已被改变 (
|
|
QEvent.ActionRemoved |
动作已被移除 (
|
|
QEvent.ActivationChange |
A widget’s top-level window activation state has changed. |
|
QEvent.ApplicationActivate |
This enum has been deprecated. Use instead. |
|
QEvent.ApplicationActivated |
This enum has been deprecated. Use instead. |
|
QEvent.ApplicationDeactivate |
This enum has been deprecated. Use instead. |
|
QEvent.ApplicationFontChange |
默认应用程序字体已改变。 |
|
QEvent.ApplicationLayoutDirectionChange |
默认的应用程序布局方向已改变。 |
|
QEvent.ApplicationPaletteChange |
默认的应用程序调色板已改变。 |
|
QEvent.ApplicationStateChange |
应用程序的状态已改变。 |
|
QEvent.ApplicationWindowIconChange |
The application’s icon has changed. |
|
QEvent.ChildAdded |
对象获取子级 (
|
|
QEvent.ChildPolished |
Widget 子级被抛光 (
|
|
QEvent.ChildRemoved |
对象失去子级 (
|
|
QEvent.Clipboard |
剪贴板内容已改变。 |
|
QEvent.Close |
Widget 被关闭 (
|
|
QEvent.CloseSoftwareInputPanel |
Widget 想要关闭 SIP (软件输入面板)。 |
|
QEvent.ContentsRectChange |
The margins of the widget’s content rect changed. |
|
QEvent.ContextMenu |
上下文弹出菜单 (
|
|
QEvent.CursorChange |
The widget’s cursor has changed. |
|
QEvent.DeferredDelete |
对象将被删除,在它已被清理之后 (
|
|
QEvent.DragEnter |
光标进入 Widget 在拖放操作期间 (
|
|
QEvent.DragLeave |
光标离开 Widget 在拖放操作期间 (
|
|
QEvent.DragMove |
拖放操作正在进行中 (
|
|
QEvent.Drop |
拖放操作完成 (
|
|
QEvent.DynamicPropertyChange |
添加、更改或从对象移除动态特性。 |
|
QEvent.EnabledChange |
Widget’s enabled state has changed. |
|
QEvent.Enter |
Mouse enters widget’s boundaries (
|
|
QEvent.EnterEditFocus |
编辑器 Widget 获得编辑聚焦。
|
|
QEvent.EnterWhatsThisMode |
Send to toplevel widgets when the application enters “What’s This?” mode. |
|
QEvent.Expose |
发送给窗口,当其屏幕内容无效且需要从后备存储刷新时。 |
|
QEvent.FileOpen |
文件打开请求 (
|
|
QEvent.FocusIn |
Widget 或窗口获得键盘聚焦 (
|
|
QEvent.FocusOut |
Widget 或窗口丢失键盘聚焦 (
|
|
QEvent.FocusAboutToChange |
Widget 或窗口聚焦即将改变 (
|
|
QEvent.FontChange |
Widget’s font has changed. |
|
QEvent.Gesture |
手势被触发 (
|
|
QEvent.GestureOverride |
手势覆盖被触发 (
|
|
QEvent.GrabKeyboard |
项获得键盘抓取 (
|
|
QEvent.GrabMouse |
项获得鼠标抓取 (
|
|
QEvent.GraphicsSceneContextMenu |
Context popup menu over a graphics scene (
|
|
QEvent.GraphicsSceneDragEnter |
The cursor enters a graphics scene during a drag and drop operation (
|
|
QEvent.GraphicsSceneDragLeave |
The cursor leaves a graphics scene during a drag and drop operation (
|
|
QEvent.GraphicsSceneDragMove |
A drag and drop operation is in progress over a scene (
|
|
QEvent.GraphicsSceneDrop |
A drag and drop operation is completed over a scene (
|
|
QEvent.GraphicsSceneHelp |
用户请求用于图形场景的帮助 (
|
|
QEvent.GraphicsSceneHoverEnter |
The mouse cursor enters a hover item in a graphics scene (
|
|
QEvent.GraphicsSceneHoverLeave |
The mouse cursor leaves a hover item in a graphics scene (
|
|
QEvent.GraphicsSceneHoverMove |
The mouse cursor moves inside a hover item in a graphics scene (
|
|
QEvent.GraphicsSceneMouseDoubleClick |
Mouse press again (double click) in a graphics scene (
|
|
QEvent.GraphicsSceneMouseMove |
Move mouse in a graphics scene (
|
|
QEvent.GraphicsSceneMousePress |
Mouse press in a graphics scene (
|
|
QEvent.GraphicsSceneMouseRelease |
Mouse release in a graphics scene (
|
|
QEvent.GraphicsSceneMove |
Widget 被移除 (
|
|
QEvent.GraphicsSceneResize |
Widget 被重置尺寸 (
|
|
QEvent.GraphicsSceneWheel |
鼠标滚轮在图形场景中卷动 (
|
|
QEvent.Hide |
Widget 被隐藏 (
|
|
QEvent.HideToParent |
子级 Widget 已隐藏。 |
|
QEvent.HoverEnter |
鼠标光标进入悬停 Widget (
|
|
QEvent.HoverLeave |
鼠标光标离开悬停 Widget (
|
|
QEvent.HoverMove |
鼠标光标在悬停 Widget 内移动 (
|
|
QEvent.IconDrag |
The main icon of a window has been dragged away (
|
|
QEvent.IconTextChange |
Widget’s icon text has been changed. (Deprecated) |
|
QEvent.InputMethod |
An input method is being used (
|
|
QEvent.InputMethodQuery |
A input method query event (
|
|
QEvent.KeyboardLayoutChange |
键盘布局已改变。 |
|
QEvent.KeyPress |
键按下 (
|
|
QEvent.KeyRelease |
键释放 (
|
|
QEvent.LanguageChange |
应用程序翻译已改变。 |
|
QEvent.LayoutDirectionChange |
布局的方向已改变。 |
|
QEvent.LayoutRequest |
Widget 布局需要重做。 |
|
QEvent.Leave |
Mouse leaves widget’s boundaries. |
|
QEvent.LeaveEditFocus |
An editor widget loses focus for editing. QT_KEYPAD_NAVIGATION must be defined. |
|
QEvent.LeaveWhatsThisMode |
Send to toplevel widgets when the application leaves “What’s This?” mode. |
|
QEvent.LocaleChange |
系统区域设置已改变。 |
|
QEvent.NonClientAreaMouseButtonDblClick |
A mouse double click occurred outside the client area (
|
|
QEvent.NonClientAreaMouseButtonPress |
A mouse button press occurred outside the client area (
|
|
QEvent.NonClientAreaMouseButtonRelease |
A mouse button release occurred outside the client area (
|
|
QEvent.NonClientAreaMouseMove |
A mouse move occurred outside the client area (
|
|
QEvent.MacSizeChange |
The user changed his widget sizes (macOS only). |
|
QEvent.MetaCall |
An asynchronous method invocation via
|
|
QEvent.ModifiedChange |
Widgets modification state has been changed. |
|
QEvent.MouseButtonDblClick |
再次按下鼠标 (
|
|
QEvent.MouseButtonPress |
鼠标按下 (
|
|
QEvent.MouseButtonRelease |
鼠标释放 (
|
|
QEvent.MouseMove |
鼠标移动 (
|
|
QEvent.MouseTrackingChange |
鼠标跟踪状态已改变。 |
|
QEvent.Move |
Widget’s position changed (
|
|
QEvent.NativeGesture |
The system has detected a gesture (
|
|
QEvent.OrientationChange |
The screens orientation has changes (
|
|
QEvent.Paint |
必要的屏幕更新 (
|
|
QEvent.PaletteChange |
Palette of the widget changed. |
|
QEvent.ParentAboutToChange |
The widget parent is about to change. |
|
QEvent.ParentChange |
The widget parent has changed. |
|
QEvent.PlatformPanel |
A platform specific panel has been requested. |
|
QEvent.PlatformSurface |
本机平台表面已被创建或即将被销毁 (
|
|
QEvent.Polish |
Widget 被抛光。 |
|
QEvent.PolishRequest |
Widget 应该被抛光。 |
|
QEvent.QueryWhatsThis |
The widget should accept the event if it has “What’s This?” help (
|
|
QEvent.ReadOnlyChange |
Widget’s read-only state has changed (since Qt 5.4). |
|
QEvent.RequestSoftwareInputPanel |
A widget wants to open a software input panel (SIP). |
|
QEvent.Resize |
Widget’s size changed (
|
|
QEvent.ScrollPrepare |
The object needs to fill in its geometry information (
|
|
QEvent.Scroll |
The object needs to scroll to the supplied position (
|
|
QEvent.Shortcut |
Key press in child for shortcut key handling (
|
|
QEvent.ShortcutOverride |
在子级中按下键,为覆盖快捷键处理 (
|
|
QEvent.Show |
Widget 被展示在屏幕上 (
|
|
QEvent.ShowToParent |
子级 Widget 已被展示。 |
|
QEvent.SockAct |
套接字被激活,用于实现
|
|
QEvent.StateMachineSignal |
交付给状态机的信号 (
|
|
QEvent.StateMachineWrapped |
事件是包裹器,即:包含另一事件 (
|
|
QEvent.StatusTip |
A status tip is requested (
|
|
QEvent.StyleChange |
Widget’s style has been changed. |
|
QEvent.TabletMove |
Wacom 平板移动 (
|
|
QEvent.TabletPress |
Wacom 数位板按下 (
|
|
QEvent.TabletRelease |
Wacom 数位板释放 (
|
|
QEvent.TabletEnterProximity |
Wacom tablet enter proximity event (
|
|
QEvent.TabletLeaveProximity |
Wacom tablet leave proximity event (
|
|
QEvent.TabletTrackingChange |
The Wacom tablet tracking state has changed (since Qt 5.9). |
|
QEvent.ThreadChange |
The object is moved to another thread. This is the last event sent to this object in the previous thread. See
|
|
QEvent.Timer |
常规计时器事件 (
|
|
QEvent.ToolBarChange |
The toolbar button is toggled on macOS. |
|
QEvent.ToolTip |
请求工具提示 (
|
|
QEvent.ToolTipChange |
The widget’s tooltip has changed. |
|
QEvent.TouchBegin |
Beginning of a sequence of touch-screen or track-pad events (
|
|
QEvent.TouchCancel |
取消触摸事件序列 (
|
|
QEvent.TouchEnd |
触摸事件序列结束 (
|
|
QEvent.TouchUpdate |
触摸屏事件 (
|
|
QEvent.UngrabKeyboard |
项丢失键盘抓取 (
|
|
QEvent.UngrabMouse |
项丢失鼠标抓取 (
|
|
QEvent.UpdateLater |
Widget 应被队列以在稍后重新描绘。 |
|
QEvent.UpdateRequest |
Widget 应被重新描绘。 |
|
QEvent.WhatsThis |
The widget should reveal “What’s This?” help (
|
|
QEvent.WhatsThisClicked |
A link in a widget’s “What’s This?” help was clicked. |
|
QEvent.Wheel |
鼠标滚轮卷动 (
|
|
QEvent.WinEventAct |
发生特定窗口激活事件。 |
|
QEvent.WindowActivate |
窗口被激活。 |
|
QEvent.WindowBlocked |
窗口被模态对话框阻塞。 |
|
QEvent.WindowDeactivate |
窗口被取消激活。 |
|
QEvent.WindowIconChange |
The window’s icon has changed. |
|
QEvent.WindowStateChange |
|
|
QEvent.WindowTitleChange |
窗口标题已改变。 |
|
QEvent.WindowUnblocked |
窗口被解除阻塞在退出模态对话框后。 |
|
QEvent.WinIdChange |
此本机 Widget 窗口系统标识符已改变。 |
|
QEvent.ZOrderChange |
The widget’s z-order has changed. This event is never sent to top level windows. |
用户事件应具有的值,介于
User
and
MaxUser
:
|
常量 |
描述 |
|---|---|
|
QEvent.User |
用户定义事件。 |
|
QEvent.MaxUser |
上次用户事件 ID。 |
为方便起见,可以使用
registerEventType()
function to register and reserve a custom event type for your application. Doing so will allow you to avoid accidentally re-using a custom event type already in use elsewhere in your application.
PySide2.QtCore.QEvent.
accept
(
)
¶
设置事件对象的接受标志,相当于调用
setAccepted
(true)。
设置接受参数指示事件接收器想要事件。不想要事件可能被传播给父级 Widget。
另请参阅
PySide2.QtCore.QEvent.
ignore
(
)
¶
清零事件对象的接受标志参数,相当于调用
setAccepted
(false).
清零接受参数指示事件接收器不想要事件。不想要事件被传播给父级 Widget。
另请参阅
PySide2.QtCore.QEvent.
isAccepted
(
)
¶
bool
PySide2.QtCore.QEvent.
registerEventType
(
[
hint=-1
]
)
¶
hint
–
int
int
注册并返回自定义事件类型。
hint
提供将被使用若可用,否则返回值介于
User
and
MaxUser
尚未被注册。
hint
被忽略若其值不介于
User
and
MaxUser
.
返回 -1 若已获取所有可用值或程序正关闭。
PySide2.QtCore.QEvent.
setAccepted
(
accepted
)
¶
accepted
–
bool
另请参阅
PySide2.QtCore.QEvent.
spontaneous
(
)
¶
bool
返回
true
若事件发源于应用程序外 (系统事件);否则返回
false
.
此函数的返回值未定义,对于描绘事件。