继承者: QGestureEvent , QWindowStateChangeEvent , QClipboardEvent , QShortcutEvent , QToolBarChangeEvent , QFileOpenEvent , QActionEvent , QWhatsThisClickedEvent , QStatusTipEvent , QHelpEvent , QDragLeaveEvent , QAccessibleEvent , QDropEvent , QDragMoveEvent , QDragEnterEvent , QInputMethodEvent , QHideEvent , QShowEvent , QIconDragEvent , QGraphicsSceneEvent , QGraphicsSceneWheelEvent , QGraphicsSceneMouseEvent , QGraphicsSceneMoveEvent , QGraphicsSceneResizeEvent , QGraphicsSceneDragDropEvent , QGraphicsSceneHelpEvent , QGraphicsSceneHoverEvent , QGraphicsSceneContextMenuEvent , QCloseEvent , QResizeEvent , QDynamicPropertyChangeEvent , QMoveEvent , QChildEvent , QPaintEvent , QTimerEvent , QFocusEvent , QHoverEvent , QInputEvent , QKeyEvent , QTabletEvent , QWheelEvent , QMouseEvent , QTouchEvent , QContextMenuEvent , QStateMachine.WrappedEvent , QStateMachine.SignalEvent
PySide.QtCore.QEvent class is the base class of all event classes. Event objects contain event parameters.
Qt 的主事件循环 ( QCoreApplication.exec() ) fetches native window system events from the event queue, translates them into QEvents, and sends the translated events to PySide.QtCore.QObject s.
通常,事件来自底层窗口系统 ( PySide.QtCore.QEvent.spontaneous() returns true), but it is also possible to manually send events using QCoreApplication.sendEvent() and QCoreApplication.postEvent() ( PySide.QtCore.QEvent.spontaneous() returns false).
QObjects 接收事件通过让其 QObject.event() function called. The function can be reimplemented in subclasses to customize event handling and add additional event types; QWidget.event() is a notable example. By default, events are dispatched to event handlers like QObject.timerEvent() and QWidget.mouseMoveEvent() . QObject.installEventFilter() allows an object to intercept events destined for another object.
The basic PySide.QtCore.QEvent contains only an event type parameter and an “accept” flag. The accept flag set with PySide.QtCore.QEvent.accept() , and cleared with PySide.QtCore.QEvent.ignore() . It is set by default, but don't rely on this as subclasses may choose to clear it in their constructor.
子类化的 PySide.QtCore.QEvent contain additional parameters that describe the particular event.
| 参数: | type – PySide.QtCore.QEvent.Type |
|---|
构造事件对象,根据类型 type .
此枚举类型定义 Qt 中的有效事件类型。事件类型和用于每个类型的专用类如下:
| 常量 | 描述 |
|---|---|
| QEvent.None | 不是事件。 |
| QEvent.AccessibilityDescription | Used to query accessibility description texts ( PySide.QtGui.QAccessibleEvent ). |
| QEvent.AccessibilityHelp | Used to query accessibility help texts ( PySide.QtGui.QAccessibleEvent ). |
| QEvent.AccessibilityPrepare | Accessibility information is requested. |
| QEvent.ActionAdded | 新的动作已被添加 ( PySide.QtGui.QActionEvent ). |
| QEvent.ActionChanged | 动作已被改变 ( PySide.QtGui.QActionEvent ). |
| QEvent.ActionRemoved | 动作已被移除 ( PySide.QtGui.QActionEvent ). |
| QEvent.ActivationChange | Widget 的顶层窗口激活状态已更改。 |
| QEvent.ApplicationActivate | The application has been made available to the user. |
| QEvent.ApplicationActivated | This enum has been deprecated. Use ApplicationActivate 代替。 |
| QEvent.ApplicationDeactivate | The application has been suspended, and is unavailable to the user. |
| QEvent.ApplicationFontChange | 默认应用程序字体已改变。 |
| QEvent.ApplicationLayoutDirectionChange | 默认的应用程序布局方向已改变。 |
| QEvent.ApplicationPaletteChange | 默认的应用程序调色板已改变。 |
| QEvent.ApplicationWindowIconChange | 应用程序的图标已改变。 |
| QEvent.ChildAdded | 对象获取子级 ( PySide.QtCore.QChildEvent ). |
| QEvent.ChildInserted | 对象获取子级 ( PySide.QtCore.QChildEvent ). Qt3Support only, use ChildAdded 代替。 |
| QEvent.ChildPolished | Widget 子级被抛光 ( PySide.QtCore.QChildEvent ). |
| QEvent.ChildRemoved | 对象失去子级 ( PySide.QtCore.QChildEvent ). |
| QEvent.Clipboard | The clipboard contents have changed ( PySide.QtGui.QClipboardEvent ). |
| QEvent.Close | Widget 被关闭 ( PySide.QtGui.QCloseEvent ). |
| QEvent.CloseSoftwareInputPanel | Widget 想要关闭 SIP (软件输入面板)。 |
| QEvent.ContentsRectChange | Widget 的内容矩形改变边距。 |
| QEvent.ContextMenu | 上下文弹出菜单 ( PySide.QtGui.QContextMenuEvent ). |
| QEvent.CursorChange | Widget 的光标已改变。 |
| QEvent.DeferredDelete | The object will be deleted after it has cleaned up. |
| QEvent.DragEnter | 光标进入 Widget 在拖放操作期间 ( PySide.QtGui.QDragEnterEvent ). |
| QEvent.DragLeave | 光标离开 Widget 在拖放操作期间 ( PySide.QtGui.QDragLeaveEvent ). |
| QEvent.DragMove | 拖放操作正在进行中 ( PySide.QtGui.QDragMoveEvent ). |
| QEvent.Drop | 拖放操作完成 ( PySide.QtGui.QDropEvent ). |
| QEvent.EnabledChange | Widget 的被启用状态已改变。 |
| 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.FileOpen | 文件打开请求 ( PySide.QtGui.QFileOpenEvent ). |
| QEvent.FocusIn | Widget gains keyboard focus ( PySide.QtGui.QFocusEvent ). |
| QEvent.FocusOut | Widget loses keyboard focus ( PySide.QtGui.QFocusEvent ). |
| QEvent.FontChange | Widget 的字体已改变。 |
| QEvent.GrabKeyboard | 项获得键盘抓取 ( PySide.QtGui.QGraphicsItem 仅)。 |
| QEvent.GrabMouse | 项获得鼠标抓取 ( PySide.QtGui.QGraphicsItem 仅)。 |
| QEvent.GraphicsSceneContextMenu | Context popup menu over a graphics scene ( PySide.QtGui.QGraphicsSceneContextMenuEvent ). |
| QEvent.GraphicsSceneDragEnter | The cursor enters a graphics scene during a drag and drop operation ( PySide.QtGui.QGraphicsSceneDragDropEvent ). |
| QEvent.GraphicsSceneDragLeave | The cursor leaves a graphics scene during a drag and drop operation ( PySide.QtGui.QGraphicsSceneDragDropEvent ). |
| QEvent.GraphicsSceneDragMove | A drag and drop operation is in progress over a scene ( PySide.QtGui.QGraphicsSceneDragDropEvent ). |
| QEvent.GraphicsSceneDrop | A drag and drop operation is completed over a scene ( PySide.QtGui.QGraphicsSceneDragDropEvent ). |
| QEvent.GraphicsSceneHelp | 用户请求用于图形场景的帮助 ( PySide.QtGui.QHelpEvent ). |
| QEvent.GraphicsSceneHoverEnter | The mouse cursor enters a hover item in a graphics scene ( PySide.QtGui.QGraphicsSceneHoverEvent ). |
| QEvent.GraphicsSceneHoverLeave | The mouse cursor leaves a hover item in a graphics scene ( PySide.QtGui.QGraphicsSceneHoverEvent ). |
| QEvent.GraphicsSceneHoverMove | The mouse cursor moves inside a hover item in a graphics scene ( PySide.QtGui.QGraphicsSceneHoverEvent ). |
| QEvent.GraphicsSceneMouseDoubleClick | Mouse press again (double click) in a graphics scene ( PySide.QtGui.QGraphicsSceneMouseEvent ). |
| QEvent.GraphicsSceneMouseMove | Move mouse in a graphics scene ( PySide.QtGui.QGraphicsSceneMouseEvent ). |
| QEvent.GraphicsSceneMousePress | Mouse press in a graphics scene ( PySide.QtGui.QGraphicsSceneMouseEvent ). |
| QEvent.GraphicsSceneMouseRelease | Mouse release in a graphics scene ( PySide.QtGui.QGraphicsSceneMouseEvent ). |
| QEvent.GraphicsSceneMove | Widget 被移除 ( PySide.QtGui.QGraphicsSceneMoveEvent ). |
| QEvent.GraphicsSceneResize | Widget 被重置尺寸 ( PySide.QtGui.QGraphicsSceneResizeEvent ). |
| QEvent.GraphicsSceneWheel | 鼠标滚轮在图形场景中卷动 ( PySide.QtGui.QGraphicsSceneWheelEvent ). |
| QEvent.Hide | Widget 被隐藏 ( PySide.QtGui.QHideEvent ). |
| QEvent.HideToParent | 子级 Widget 已隐藏。 |
| QEvent.HoverEnter | 鼠标光标进入悬停 Widget ( PySide.QtGui.QHoverEvent ). |
| QEvent.HoverLeave | 鼠标光标离开悬停 Widget ( PySide.QtGui.QHoverEvent ). |
| QEvent.HoverMove | 鼠标光标在悬停 Widget 内移动 ( PySide.QtGui.QHoverEvent ). |
| QEvent.IconDrag | The main icon of a window has been dragged away ( PySide.QtGui.QIconDragEvent ). |
| QEvent.IconTextChange | Widget's icon text has been changed. |
| QEvent.InputMethod | An input method is being used ( PySide.QtGui.QInputMethodEvent ). |
| QEvent.KeyPress | 键按下 ( PySide.QtGui.QKeyEvent ). |
| QEvent.KeyRelease | 键释放 ( PySide.QtGui.QKeyEvent ). |
| QEvent.LanguageChange | 应用程序翻译已改变。 |
| QEvent.LayoutDirectionChange | 布局的方向已改变。 |
| QEvent.LayoutRequest | Widget 布局需要重做。 |
| QEvent.Leave | 鼠标离开 Widget 边界。 |
| QEvent.LeaveEditFocus | An editor widget loses focus for editing. |
| 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 (Mac OS X only). |
| QEvent.MenubarUpdated | The window's menu bar has been updated. |
| QEvent.MetaCall | An asynchronous method invocation via QMetaObject.invokeMethod() . |
| QEvent.ModifiedChange | Widgets modification state has been changed. |
| QEvent.MouseButtonDblClick | 再次按下鼠标 ( PySide.QtGui.QMouseEvent ). |
| QEvent.MouseButtonPress | 鼠标按下 ( PySide.QtGui.QMouseEvent ). |
| QEvent.MouseButtonRelease | 鼠标释放 ( PySide.QtGui.QMouseEvent ). |
| QEvent.MouseMove | 鼠标移动 ( PySide.QtGui.QMouseEvent ). |
| QEvent.MouseTrackingChange | 鼠标跟踪状态已改变。 |
| QEvent.Move | Widget 的位置被改变 ( PySide.QtGui.QMoveEvent ). |
| QEvent.Paint | 必要的屏幕更新 ( PySide.QtGui.QPaintEvent ). |
| 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.Polish | Widget 被抛光。 |
| QEvent.PolishRequest | Widget 应该被抛光。 |
| QEvent.QueryWhatsThis | The widget should accept the event if it has “What's This?” help. |
| QEvent.RequestSoftwareInputPanel | A widget wants to open a software input panel (SIP). |
| QEvent.Resize | Widget 大小改变 ( PySide.QtGui.QResizeEvent ). |
| QEvent.Shortcut | Key press in child for shortcut key handling ( PySide.QtGui.QShortcutEvent ). |
| QEvent.ShortcutOverride | 在子级中按下键,为覆盖快捷键处理 ( PySide.QtGui.QKeyEvent ). |
| QEvent.Show | Widget 被展示在屏幕上 ( PySide.QtGui.QShowEvent ). |
| QEvent.ShowToParent | 子级 Widget 已被展示。 |
| QEvent.SockAct | 套接字被激活,用于实现 PySide.QtCore.QSocketNotifier . |
| QEvent.StateMachineSignal | 交付给状态机的信号 ( QStateMachine.SignalEvent ). |
| QEvent.StateMachineWrapped | 事件是包裹器,即:包含另一事件 ( QStateMachine.WrappedEvent ). |
| QEvent.StatusTip | A status tip is requested ( PySide.QtGui.QStatusTipEvent ). |
| QEvent.StyleChange | Widget 的样式已改变。 |
| QEvent.TabletMove | Wacom 平板移动 ( PySide.QtGui.QTabletEvent ). |
| QEvent.TabletPress | Wacom 数位板按下 ( PySide.QtGui.QTabletEvent ). |
| QEvent.TabletRelease | Wacom 数位板释放 ( PySide.QtGui.QTabletEvent ). |
| QEvent.OkRequest | Ok button in decoration pressed. Supported only for Windows CE. |
| QEvent.TabletEnterProximity | Wacom tablet enter proximity event ( PySide.QtGui.QTabletEvent ), sent to PySide.QtGui.QApplication . |
| QEvent.TabletLeaveProximity | Wacom tablet leave proximity event ( PySide.QtGui.QTabletEvent ), sent to PySide.QtGui.QApplication . |
| QEvent.Timer | 常规计时器事件 ( PySide.QtCore.QTimerEvent ). |
| QEvent.ToolBarChange | The toolbar button is toggled on Mac OS X. |
| QEvent.ToolTip | 请求工具提示 ( PySide.QtGui.QHelpEvent ). |
| QEvent.ToolTipChange | Widget 工具提示已改变。 |
| QEvent.UngrabKeyboard | 项丢失键盘抓取 ( PySide.QtGui.QGraphicsItem 仅)。 |
| QEvent.UngrabMouse | 项丢失鼠标抓取 ( PySide.QtGui.QGraphicsItem 仅)。 |
| QEvent.UpdateLater | Widget 应被队列以在稍后重新描绘。 |
| QEvent.UpdateRequest | Widget 应被重新描绘。 |
| QEvent.WhatsThis | The widget should reveal “What's This?” help ( PySide.QtGui.QHelpEvent ). |
| QEvent.WhatsThisClicked | A link in a widget's “What's This?” help was clicked. |
| QEvent.Wheel | 鼠标滚轮卷动 ( PySide.QtGui.QWheelEvent ). |
| QEvent.WinEventAct | 发生特定窗口激活事件。 |
| QEvent.WindowActivate | 窗口被激活。 |
| QEvent.WindowBlocked | 窗口被模态对话框阻塞。 |
| QEvent.WindowDeactivate | 窗口被取消激活。 |
| QEvent.WindowIconChange | 窗口的图标已改变。 |
| QEvent.WindowStateChange | window's state (最小化、最大化或全屏) 已改变 ( PySide.QtGui.QWindowStateChangeEvent ). |
| QEvent.WindowTitleChange | 窗口标题已改变。 |
| QEvent.WindowUnblocked | 窗口被解除阻塞在退出模态对话框后。 |
| QEvent.ZOrderChange | 小部件 Z 次序已改变。此事件从不发送给顶层窗口。 |
| QEvent.KeyboardLayoutChange | 键盘布局已改变。 |
| QEvent.DynamicPropertyChange | A dynamic property was added, changed or removed from the object. |
| QEvent.TouchBegin | Beginning of a sequence of touch-screen and/or track-pad events ( PySide.QtGui.QTouchEvent ) |
| QEvent.TouchUpdate | 触摸屏事件 ( PySide.QtGui.QTouchEvent ) |
| QEvent.TouchEnd | 触摸事件序列结束 ( PySide.QtGui.QTouchEvent ) |
| QEvent.WinIdChange | The window system identifer for this native widget has changed |
| QEvent.Gesture | 手势被触发 ( PySide.QtGui.QGestureEvent ) |
| QEvent.GestureOverride | 手势覆盖被触发 ( PySide.QtGui.QGestureEvent ) |
用户事件应具有的值,介于 User and MaxUser :
| 常量 | 描述 |
|---|---|
| QEvent.User | 用户定义事件。 |
| QEvent.MaxUser | 上次用户事件 ID。 |
为方便起见,可以使用 PySide.QtCore.QEvent.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.
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
设置接受参数指示事件接收器想要事件。不想要事件可能被传播给父级 Widget。
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
清零接受参数指示事件接收器不想要事件。不想要事件被传播给父级 Widget。
| 返回类型: | PySide.QtCore.bool |
|---|
| 参数: | hint – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.int |
注册并返回自定义事件类型。 hint 提供将被使用若可用,否则返回值介于 QEvent.User and QEvent.MaxUser 尚未被注册。 hint 被忽略若其值不介于 QEvent.User and QEvent.MaxUser .
| 参数: | accepted – PySide.QtCore.bool |
|---|
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the event originated outside the application (a system event); otherwise returns false.
此函数的返回值未定义,对于描绘事件。
| 返回类型: | PySide.QtCore.QEvent.Type |
|---|
返回事件类型。