QEvent

Inheritance diagram of QEvent

Inherited by: QClipboardEvent, QShortcutEvent, QToolBarChangeEvent, QFileOpenEvent, QActionEvent, QWhatsThisClickedEvent, QStatusTipEvent, QHelpEvent, QDragLeaveEvent, QDropEvent, QDragMoveEvent, QDragEnterEvent, QInputMethodEvent, QHideEvent, QShowEvent, QIconDragEvent, QDynamicPropertyChangeEvent, QCloseEvent, QChildEvent, QResizeEvent, QTimerEvent, QMoveEvent, QPaintEvent, QAccessibleEvent, QFocusEvent, QHoverEvent, QGraphicsSceneEvent, QGraphicsSceneMoveEvent, QGraphicsSceneResizeEvent, QGraphicsSceneDragDropEvent, QGraphicsSceneHelpEvent, QGraphicsSceneHoverEvent, QGraphicsSceneContextMenuEvent, QGraphicsSceneWheelEvent, QGraphicsSceneMouseEvent, QInputEvent, QTouchEvent, QContextMenuEvent, QKeyEvent, QTabletEvent, QWheelEvent, QMouseEvent, QGestureEvent, QWindowStateChangeEvent, QStateMachine.WrappedEvent, QStateMachine.SignalEvent

Synopsis

Functions

Static functions

Detailed Description

The PySide.QtCore.QEvent class is the base class of all event classes. Event objects contain event parameters.

Qt’s main event loop ( 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.

In general, events come from the underlying window system ( 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 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() 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.

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

class PySide.QtCore.QEvent(type)
Parameters:typePySide.QtCore.QEvent.Type

Contructs an event object of type type .

PySide.QtCore.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:

Constant Description
QEvent.None Not an event.
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 A new action has been added ( PySide.QtGui.QActionEvent ).
QEvent.ActionChanged An action has been changed ( PySide.QtGui.QActionEvent ).
QEvent.ActionRemoved An action has been removed ( PySide.QtGui.QActionEvent ).
QEvent.ActivationChange A widget’s top-level window activation state has changed.
QEvent.ApplicationActivate The application has been made available to the user.
QEvent.ApplicationActivated This enum has been deprecated. Use ApplicationActivate instead.
QEvent.ApplicationDeactivate The application has been suspended, and is unavailable to the user.
QEvent.ApplicationFontChange The default application font has changed.
QEvent.ApplicationLayoutDirectionChange The default application layout direction has changed.
QEvent.ApplicationPaletteChange The default application palette has changed.
QEvent.ApplicationWindowIconChange The application’s icon has changed.
QEvent.ChildAdded An object gets a child ( PySide.QtCore.QChildEvent ).
QEvent.ChildInserted An object gets a child ( PySide.QtCore.QChildEvent ). Qt3Support only, use ChildAdded instead.
QEvent.ChildPolished A widget child gets polished ( PySide.QtCore.QChildEvent ).
QEvent.ChildRemoved An object loses a child ( PySide.QtCore.QChildEvent ).
QEvent.Clipboard The clipboard contents have changed ( PySide.QtGui.QClipboardEvent ).
QEvent.Close Widget was closed ( PySide.QtGui.QCloseEvent ).
QEvent.CloseSoftwareInputPanel A widget wants to close the software input panel (SIP).
QEvent.ContentsRectChange The margins of the widget’s content rect changed.
QEvent.ContextMenu Context popup menu ( PySide.QtGui.QContextMenuEvent ).
QEvent.CursorChange The widget’s cursor has changed.
QEvent.DeferredDelete The object will be deleted after it has cleaned up.
QEvent.DragEnter The cursor enters a widget during a drag and drop operation ( PySide.QtGui.QDragEnterEvent ).
QEvent.DragLeave The cursor leaves a widget during a drag and drop operation ( PySide.QtGui.QDragLeaveEvent ).
QEvent.DragMove A drag and drop operation is in progress ( PySide.QtGui.QDragMoveEvent ).
QEvent.Drop A drag and drop operation is completed ( PySide.QtGui.QDropEvent ).
QEvent.EnabledChange Widget’s enabled state has changed.
QEvent.Enter Mouse enters widget’s boundaries.
QEvent.EnterEditFocus An editor widget gains focus for editing.
QEvent.EnterWhatsThisMode Send to toplevel widgets when the application enters “What’s This?” mode.
QEvent.FileOpen File open request ( PySide.QtGui.QFileOpenEvent ).
QEvent.FocusIn Widget gains keyboard focus ( PySide.QtGui.QFocusEvent ).
QEvent.FocusOut Widget loses keyboard focus ( PySide.QtGui.QFocusEvent ).
QEvent.FontChange Widget’s font has changed.
QEvent.GrabKeyboard Item gains keyboard grab ( PySide.QtGui.QGraphicsItem only).
QEvent.GrabMouse Item gains mouse grab ( PySide.QtGui.QGraphicsItem only).
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 The user requests help for a graphics scene ( 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 was moved ( PySide.QtGui.QGraphicsSceneMoveEvent ).
QEvent.GraphicsSceneResize Widget was resized ( PySide.QtGui.QGraphicsSceneResizeEvent ).
QEvent.GraphicsSceneWheel Mouse wheel rolled in a graphics scene ( PySide.QtGui.QGraphicsSceneWheelEvent ).
QEvent.Hide Widget was hidden ( PySide.QtGui.QHideEvent ).
QEvent.HideToParent A child widget has been hidden.
QEvent.HoverEnter The mouse cursor enters a hover widget ( PySide.QtGui.QHoverEvent ).
QEvent.HoverLeave The mouse cursor leaves a hover widget ( PySide.QtGui.QHoverEvent ).
QEvent.HoverMove The mouse cursor moves inside a hover 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 Key press ( PySide.QtGui.QKeyEvent ).
QEvent.KeyRelease Key release ( PySide.QtGui.QKeyEvent ).
QEvent.LanguageChange The application translation changed.
QEvent.LayoutDirectionChange The direction of layouts changed.
QEvent.LayoutRequest Widget layout needs to be redone.
QEvent.Leave Mouse leaves widget’s boundaries.
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 The system locale has changed.
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 Mouse press again ( PySide.QtGui.QMouseEvent ).
QEvent.MouseButtonPress Mouse press ( PySide.QtGui.QMouseEvent ).
QEvent.MouseButtonRelease Mouse release ( PySide.QtGui.QMouseEvent ).
QEvent.MouseMove Mouse move ( PySide.QtGui.QMouseEvent ).
QEvent.MouseTrackingChange The mouse tracking state has changed.
QEvent.Move Widget’s position changed ( PySide.QtGui.QMoveEvent ).
QEvent.Paint Screen update necessary ( 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.Polish The widget is polished.
QEvent.PolishRequest The widget should be polished.
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’s size changed ( PySide.QtGui.QResizeEvent ).
QEvent.Shortcut Key press in child for shortcut key handling ( PySide.QtGui.QShortcutEvent ).
QEvent.ShortcutOverride Key press in child, for overriding shortcut key handling ( PySide.QtGui.QKeyEvent ).
QEvent.Show Widget was shown on screen ( PySide.QtGui.QShowEvent ).
QEvent.ShowToParent A child widget has been shown.
QEvent.SockAct Socket activated, used to implement PySide.QtCore.QSocketNotifier .
QEvent.StateMachineSignal A signal delivered to a state machine ( QStateMachine.SignalEvent ).
QEvent.StateMachineWrapped The event is a wrapper for, i.e., contains, another event ( QStateMachine.WrappedEvent ).
QEvent.StatusTip A status tip is requested ( PySide.QtGui.QStatusTipEvent ).
QEvent.StyleChange Widget’s style has been changed.
QEvent.TabletMove Wacom tablet move ( PySide.QtGui.QTabletEvent ).
QEvent.TabletPress Wacom tablet press ( PySide.QtGui.QTabletEvent ).
QEvent.TabletRelease Wacom tablet release ( 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 Regular timer events ( PySide.QtCore.QTimerEvent ).
QEvent.ToolBarChange The toolbar button is toggled on Mac OS X.
QEvent.ToolTip A tooltip was requested ( PySide.QtGui.QHelpEvent ).
QEvent.ToolTipChange The widget’s tooltip has changed.
QEvent.UngrabKeyboard Item loses keyboard grab ( PySide.QtGui.QGraphicsItem only).
QEvent.UngrabMouse Item loses mouse grab ( PySide.QtGui.QGraphicsItem only).
QEvent.UpdateLater The widget should be queued to be repainted at a later time.
QEvent.UpdateRequest The widget should be repainted.
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 Mouse wheel rolled ( PySide.QtGui.QWheelEvent ).
QEvent.WinEventAct A Windows-specific activation event has occurred.
QEvent.WindowActivate Window was activated.
QEvent.WindowBlocked The window is blocked by a modal dialog.
QEvent.WindowDeactivate Window was deactivated.
QEvent.WindowIconChange The window’s icon has changed.
QEvent.WindowStateChange The window's state (minimized, maximized or full-screen) has changed ( PySide.QtGui.QWindowStateChangeEvent ).
QEvent.WindowTitleChange The window title has changed.
QEvent.WindowUnblocked The window is unblocked after a modal dialog exited.
QEvent.ZOrderChange The widget’s z-order has changed. This event is never sent to top level windows.
QEvent.KeyboardLayoutChange The keyboard layout has changed.
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 Touch-screen event ( PySide.QtGui.QTouchEvent )
QEvent.TouchEnd End of touch-event sequence ( PySide.QtGui.QTouchEvent )
QEvent.WinIdChange The window system identifer for this native widget has changed
QEvent.Gesture A gesture was triggered ( PySide.QtGui.QGestureEvent )
QEvent.GestureOverride A gesture override was triggered ( PySide.QtGui.QGestureEvent )

User events should have values between User and MaxUser :

Constant Description
QEvent.User User-defined event.
QEvent.MaxUser Last user event ID.

For convenience, you can use the 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.

PySide.QtCore.QEvent.accept()

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

PySide.QtCore.QEvent.ignore()

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.

PySide.QtCore.QEvent.isAccepted()
Return type:PySide.QtCore.bool
static PySide.QtCore.QEvent.registerEventType([hint=-1])
Parameters:hintPySide.QtCore.int
Return type:PySide.QtCore.int

Registers and returns a custom event type. The 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 .

PySide.QtCore.QEvent.setAccepted(accepted)
Parameters:acceptedPySide.QtCore.bool
PySide.QtCore.QEvent.spontaneous()
Return type:PySide.QtCore.bool

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

PySide.QtCore.QEvent.type()
Return type:PySide.QtCore.QEvent.Type

Returns the event type.