QEvent Class Reference

[ QtCore module]

The QEvent class is the base class of all event classes. Event objects contain event parameters. 更多...

Inherited by QActionEvent , QChildEvent , QCloseEvent , QDragLeaveEvent , QDropEvent , QDynamicPropertyChangeEvent , QFileOpenEvent , QFocusEvent , QGestureEvent , QGraphicsSceneEvent , QHelpEvent , QHideEvent , QHoverEvent , QIconDragEvent , QInputEvent , QInputMethodEvent , QMoveEvent , QPaintEvent , QResizeEvent , QShortcutEvent , QShowEvent , SignalEvent , WrappedEvent , QStatusTipEvent , QTimerEvent , QWhatsThisClickedEvent and QWindowStateChangeEvent .

类型

方法

Static Methods


详细描述

The 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 QObject s.

In general, events come from the underlying window system ( spontaneous () returns true), but it is also possible to manually send events using QCoreApplication.sendEvent () and QCoreApplication.postEvent () ( spontaneous () 返回 false).

QObjects receive events by having their 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 () 和 QWidget.mouseMoveEvent (). QObject.installEventFilter () allows an object to intercept events destined for another 对象。

The basic QEvent contains only an event type parameter and an "accept" flag. The accept flag set with accept (),而清零采用 ignore (). It is set by default, but don't rely on this as subclasses may choose to clear it in their 构造函数。

Subclasses of QEvent contain additional parameters that describe the particular event.


类型文档编制

QEvent.Type

This enum type defines the valid event types in Qt. The event types and the specialized classes for each type are as follows:

常量 描述
QEvent.None 0 不是事件。
QEvent.AccessibilityDescription 130 Used to query accessibility description texts ( QAccessibleEvent ).
QEvent.AccessibilityHelp 119 Used to query accessibility help texts ( QAccessibleEvent ).
QEvent.AccessibilityPrepare 86 Accessibility information is requested.
QEvent.ActionAdded 114 新的动作已被添加 ( QActionEvent ).
QEvent.ActionChanged 113 动作已被改变 ( QActionEvent ).
QEvent.ActionRemoved 115 动作已被移除 ( QActionEvent ).
QEvent.ActivationChange 99 A widget's top-level window activation state 已改变。
QEvent.ApplicationActivate 121 The application has been made available to the user.
QEvent.ApplicationActivated ApplicationActivate This enum has been deprecated. Use ApplicationActivate instead.
QEvent.ApplicationDeactivate 122 The application has been suspended, and is unavailable to the user.
QEvent.ApplicationFontChange 36 默认应用程序字体已改变。
QEvent.ApplicationLayoutDirectionChange 37 The default application layout direction has 改变。
QEvent.ApplicationPaletteChange 38 The default application palette has 改变。
QEvent.ApplicationWindowIconChange 35 应用程序的图标已改变。
QEvent.ChildAdded 68 对象获取子级 ( QChildEvent ).
QEvent.ChildInserted 70 对象获取子级 ( QChildEvent ). Qt3Support only, use ChildAdded instead.
QEvent.ChildPolished 69 Widget 子级被抛光 ( QChildEvent ).
QEvent.ChildRemoved 71 对象失去子级 ( QChildEvent ).
QEvent.Clipboard 40 The clipboard contents have changed (QClipboardEvent).
QEvent.Close 19 Widget 被关闭 ( QCloseEvent ).
QEvent.CloseSoftwareInputPanel 200 A widget wants to close the software input panel (SIP).
QEvent.ContentsRectChange 178 The margins of the widget's content rect 改变。
QEvent.ContextMenu 82 上下文弹出菜单 ( QContextMenuEvent ).
QEvent.CursorChange 183 Widget 的光标已改变。
QEvent.DeferredDelete 52 The object will be deleted after it has cleaned up.
QEvent.DragEnter 60 The cursor enters a widget during a drag and drop operation ( QDragEnterEvent ).
QEvent.DragLeave 62 The cursor leaves a widget during a drag and drop operation ( QDragLeaveEvent ).
QEvent.DragMove 61 A drag and drop operation is in progress ( QDragMoveEvent ).
QEvent.Drop 63 A drag and drop operation is completed ( QDropEvent ).
QEvent.EnabledChange 98 Widget 的被启用状态已改变。
QEvent.Enter 10 Mouse enters widget's boundaries.
QEvent.EnterEditFocus 150 编辑器 Widget 获得编辑聚焦。
QEvent.EnterWhatsThisMode 124 Send to toplevel widgets when the application enters "What's This?" mode.
QEvent.FileOpen 116 文件打开请求 ( QFileOpenEvent ).
QEvent.FocusIn 8 Widget gains keyboard focus ( QFocusEvent ).
QEvent.FocusOut 9 Widget loses keyboard focus ( QFocusEvent ).
QEvent.FontChange 97 Widget 的字体已改变。
QEvent.GrabKeyboard 188 项获得键盘抓取 ( QGraphicsItem 仅)。
QEvent.GrabMouse 186 项获得鼠标抓取 ( QGraphicsItem 仅)。
QEvent.GraphicsSceneContextMenu 159 Context popup menu over a graphics scene ( QGraphicsSceneContextMenuEvent ).
QEvent.GraphicsSceneDragEnter 164 The cursor enters a graphics scene during a drag and drop operation ( QGraphicsSceneDragDropEvent ).
QEvent.GraphicsSceneDragLeave 166 The cursor leaves a graphics scene during a drag and drop operation ( QGraphicsSceneDragDropEvent ).
QEvent.GraphicsSceneDragMove 165 A drag and drop operation is in progress over a scene ( QGraphicsSceneDragDropEvent ).
QEvent.GraphicsSceneDrop 167 A drag and drop operation is completed over a scene ( QGraphicsSceneDragDropEvent ).
QEvent.GraphicsSceneHelp 163 The user requests help for a graphics scene ( QHelpEvent ).
QEvent.GraphicsSceneHoverEnter 160 The mouse cursor enters a hover item in a graphics scene ( QGraphicsSceneHoverEvent ).
QEvent.GraphicsSceneHoverLeave 162 The mouse cursor leaves a hover item in a graphics scene ( QGraphicsSceneHoverEvent ).
QEvent.GraphicsSceneHoverMove 161 The mouse cursor moves inside a hover item in a graphics scene ( QGraphicsSceneHoverEvent ).
QEvent.GraphicsSceneMouseDoubleClick 158 Mouse press again (double click) in a graphics scene ( QGraphicsSceneMouseEvent ).
QEvent.GraphicsSceneMouseMove 155 Move mouse in a graphics scene ( QGraphicsSceneMouseEvent ).
QEvent.GraphicsSceneMousePress 156 Mouse press in a graphics scene ( QGraphicsSceneMouseEvent ).
QEvent.GraphicsSceneMouseRelease 157 Mouse release in a graphics scene ( QGraphicsSceneMouseEvent ).
QEvent.GraphicsSceneMove 182 Widget 被移除 ( QGraphicsSceneMoveEvent ).
QEvent.GraphicsSceneResize 181 Widget 被重置尺寸 ( QGraphicsSceneResizeEvent ).
QEvent.GraphicsSceneWheel 168 Mouse wheel rolled in a graphics scene ( QGraphicsSceneWheelEvent ).
QEvent.Hide 18 Widget 被隐藏 ( QHideEvent ).
QEvent.HideToParent 27 子级 Widget 已隐藏。
QEvent.HoverEnter 127 The mouse cursor enters a hover widget ( QHoverEvent ).
QEvent.HoverLeave 128 The mouse cursor leaves a hover widget ( QHoverEvent ).
QEvent.HoverMove 129 The mouse cursor moves inside a hover widget ( QHoverEvent ).
QEvent.IconDrag 96 The main icon of a window has been dragged away ( QIconDragEvent ).
QEvent.IconTextChange 101 Widget's icon text has been changed.
QEvent.InputMethod 83 An input method is being used ( QInputMethodEvent ).
QEvent.KeyPress 6 键按下 ( QKeyEvent ).
QEvent.KeyRelease 7 键释放 ( QKeyEvent ).
QEvent.LanguageChange 89 应用程序翻译已改变。
QEvent.LayoutDirectionChange 90 布局的方向已改变。
QEvent.LayoutRequest 76 Widget 布局需要重做。
QEvent.Leave 11 鼠标离开 Widget 边界。
QEvent.LeaveEditFocus 151 An editor widget loses focus for editing.
QEvent.LeaveWhatsThisMode 125 Send to toplevel widgets when the application leaves "What's This?" mode.
QEvent.LocaleChange 88 系统区域设置已改变。
QEvent.NonClientAreaMouseButtonDblClick 176 A mouse double click occurred outside the client area.
QEvent.NonClientAreaMouseButtonPress 174 A mouse button press occurred outside the client area.
QEvent.NonClientAreaMouseButtonRelease 175 A mouse button release occurred outside the client area.
QEvent.NonClientAreaMouseMove 173 A mouse move occurred outside the client area.
QEvent.MacSizeChange 177 The user changed his widget sizes (Mac OS X 仅)。
QEvent.MenubarUpdated 153 The window's menu bar has been updated.
QEvent.MetaCall 43 An asynchronous method invocation via QMetaObject.invokeMethod ().
QEvent.ModifiedChange 102 Widgets modification state has been 改变。
QEvent.MouseButtonDblClick 4 再次按下鼠标 ( QMouseEvent ).
QEvent.MouseButtonPress 2 鼠标按下 ( QMouseEvent ).
QEvent.MouseButtonRelease 3 鼠标释放 ( QMouseEvent ).
QEvent.MouseMove 5 鼠标移动 ( QMouseEvent ).
QEvent.MouseTrackingChange 109 鼠标跟踪状态已改变。
QEvent.Move 13 Widget 的位置被改变 ( QMoveEvent ).
QEvent.Paint 12 必要的屏幕更新 ( QPaintEvent ).
QEvent.PaletteChange 39 Palette of the widget changed.
QEvent.ParentAboutToChange 131 The widget parent is about to change.
QEvent.ParentChange 21 The widget parent has changed.
QEvent.PlatformPanel 212 A platform specific panel has been requested.
QEvent.Polish 75 Widget 被抛光。
QEvent.PolishRequest 74 Widget 应该被抛光。
QEvent.QueryWhatsThis 123 The widget should accept the event if it has "What's This?" help.
QEvent.RequestSoftwareInputPanel 199 A widget wants to open a software input panel (SIP).
QEvent.Resize 14 Widget 大小改变 ( QResizeEvent ).
QEvent.Shortcut 117 Key press in child for shortcut key handling ( QShortcutEvent ).
QEvent.ShortcutOverride 51 Key press in child, for overriding shortcut key handling ( QKeyEvent ).
QEvent.Show 17 Widget 被展示在屏幕上 ( QShowEvent ).
QEvent.ShowToParent 26 子级 Widget 已被展示。
QEvent.SockAct 50 套接字被激活,用于实现 QSocketNotifier .
QEvent.StateMachineSignal 192 A signal delivered to a state machine ( QStateMachine.SignalEvent ).
QEvent.StateMachineWrapped 193 The event is a wrapper for, i.e., contains, another event ( QStateMachine.WrappedEvent ).
QEvent.StatusTip 112 A status tip is requested ( QStatusTipEvent ).
QEvent.StyleChange 100 Widget 的样式已改变。
QEvent.TabletMove 87 Wacom 平板移动 ( QTabletEvent ).
QEvent.TabletPress 92 Wacom 数位板按下 ( QTabletEvent ).
QEvent.TabletRelease 93 Wacom 数位板释放 ( QTabletEvent ).
QEvent.OkRequest 94 Ok button in decoration pressed. Supported only for Windows CE.
QEvent.TabletEnterProximity 171 Wacom tablet enter proximity event ( QTabletEvent ), sent to QApplication .
QEvent.TabletLeaveProximity 172 Wacom tablet leave proximity event ( QTabletEvent ), sent to QApplication .
QEvent.Timer 1 常规计时器事件 ( QTimerEvent ).
QEvent.ToolBarChange 120 The toolbar button is toggled on Mac OS X.
QEvent.ToolTip 110 请求工具提示 ( QHelpEvent ).
QEvent.ToolTipChange 184 Widget 工具提示已改变。
QEvent.UngrabKeyboard 189 项丢失键盘抓取 ( QGraphicsItem 仅)。
QEvent.UngrabMouse 187 项丢失鼠标抓取 ( QGraphicsItem 仅)。
QEvent.UpdateLater 78 The widget should be queued to be repainted at a later time.
QEvent.UpdateRequest 77 Widget 应被重新描绘。
QEvent.WhatsThis 111 The widget should reveal "What's This?" help ( QHelpEvent ).
QEvent.WhatsThisClicked 118 A link in a widget's "What's This?" help was clicked.
QEvent.Wheel 31 鼠标滚轮卷动 ( QWheelEvent ).
QEvent.WinEventAct 132 A Windows-specific activation event has occurred.
QEvent.WindowActivate 24 窗口被激活。
QEvent.WindowBlocked 103 窗口被模态对话框阻塞。
QEvent.WindowDeactivate 25 窗口被取消激活。
QEvent.WindowIconChange 34 窗口的图标已改变。
QEvent.WindowStateChange 105 窗口状态 (minimized, maximized or full-screen) has changed ( QWindowStateChangeEvent ).
QEvent.WindowTitleChange 33 窗口标题已改变。
QEvent.WindowUnblocked 104 The window is unblocked after a modal dialog exited.
QEvent.ZOrderChange 126 The widget's z-order has changed. This event is never sent to top level windows.
QEvent.KeyboardLayoutChange 169 键盘布局已改变。
QEvent.DynamicPropertyChange 170 A dynamic property was added, changed or removed from the object.
QEvent.TouchBegin 194 Beginning of a sequence of touch-screen and/or track-pad events ( QTouchEvent )
QEvent.TouchUpdate 195 触摸屏事件 ( QTouchEvent )
QEvent.TouchEnd 196 触摸事件序列结束 ( QTouchEvent )
QEvent.WinIdChange 203 The window system identifer for this native widget has changed
QEvent.Gesture 198 手势被触发 ( QGestureEvent )
QEvent.GestureOverride 202 手势覆盖被触发 ( QGestureEvent )

用户事件应具有的值,介于 User and MaxUser :

常量 描述
QEvent.User 1000 用户定义事件。
QEvent.MaxUser 65535 上次用户事件 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.


方法文档编制

QEvent.__init__ ( self , Type   type )

构造事件对象,根据类型 type .

QEvent.__init__ ( self , QEvent )

QEvent.accept ( self )

Sets the accept flag of the event object, the equivalent of calling setAccepted(true).

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent 小部件。

另请参阅 ignore ().

QEvent.ignore ( self )

Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).

Clearing the accept parameter indicates that the event receiver does not want the event. Unwanted events might be propagated to the parent widget.

另请参阅 accept ().

bool QEvent.isAccepted ( self )

int QEvent.registerEventType (int  hint  = -1)

注册并返回自定义事件类型。 hint provided will be used if it is available, otherwise it will return a value between QEvent.User and QEvent.MaxUser that has not yet been registered. The hint is ignored if its value is not between QEvent.User and QEvent.MaxUser .

注意: 此函数是 thread-safe .

该函数在 Qt 4.4 引入。

QEvent.setAccepted ( self , bool  accepted )

bool QEvent.spontaneous ( self )

Returns true if the event originated outside the application (a system event); otherwise returns false.

The return value of this function is not defined for paint 事件。

Type QEvent.type ( self )

返回事件类型。