Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QEvent Class Reference

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

    #include <QEvent>

Inherited by QTimerEvent, QChildEvent, QCustomEvent, QInputEvent, QFocusEvent, QPaintEvent, QMoveEvent, QResizeEvent, QCloseEvent, QIconDragEvent, QShowEvent, QHideEvent, QDropEvent, QDragLeaveEvent, QFileOpenEvent, and QToolBarChangeEvent.

- List of all members, including inherited members

### Public Types

- enum Type { None, Accessibility, AccessibilityHelp, ActionChanged, ActionAdded, ..., MaxUser }

### Writable Properties

- accepted : bool

### Public Functions

- QEvent ( Type type )
- virtual ~QEvent ()
- void accept ()
- void ignore ()
- bool spontaneous () const
- Type type () const

## Detailed Description

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

Qt's main event loop (QApplication::exec()) fetches native window system events from the event queue, translates them into QEvents, and sends the translated events to QObjects.

In general, events come from the underlying window system (spontaneous() returns true), but it is also possible to manually send events using QApplication::sendEvent() and QApplication::postEvent() (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 QEvent contains only an event type parameter and an accept flag. The accept flag set with accept(), and cleared with ignore(). It is set by default, but don't rely on this as subclasses may choose to clear it in their constructor.

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

QWidget::event() QApplication::sendEvent() QApplication::postEvent() QApplication::processEvents()

See also QObject::event() and QObject::installEventFilter().

## Member Type Documentation

### enum 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` | Not an event.
`QEvent::Accessibility` | Accessibility information is requested.
`QEvent::AccessibilityHelp` | Used to query for additional information about complex widgets. QAccessibleEvent
`QEvent::ActionChanged` | An action has been changed.
`QEvent::ActionAdded` | A new action has been added.
`QEvent::ActionRemoved` | An action has been removed.
`QEvent::ActivationChange` | A widget's top-level window activation state has changed.
`QEvent::ApplicationWindowIconChange` | The application's icon has changed.
`QEvent::ApplicationFontChange` | The default application font has changed.
`QEvent::ApplicationPaletteChange` | The default application palette has changed.
`QEvent::ChildAdded` | An object gets a child, QChildEvent.
`QEvent::ChildPolished` | A widget child gets polished, QChildEvent.
`QEvent::ChildRemoved` | An object loses a child, QChildEvent.
`QEvent::Clipboard` | The clipboard contents have changed.
`QEvent::Close` | Widget was closed (permanently), QCloseEvent.
`QEvent::ContextMenu` | Context popup menu, QContextMenuEvent
`QEvent::Create` | Reserved.
`QEvent::DeferredDelete` | The object will be deleted after it has cleaned up.
`QEvent::Destroy` | Reserved.
`QEvent::DragEnter` | The cursor enters a widget during a drag and drop action, QDragEnterEvent.
`QEvent::DragLeave` | The cursor leaves a widget during a drag and drop action, QDragLeaveEvent.
`QEvent::DragMove` | A drag and drop action is in progress, QDragMoveEvent.
`QEvent::Drop` | A drag and drop action is completed, QDropEvent.
`QEvent::EnabledChange` | Widget's enabled state has changed
`QEvent::Enter` | Mouse enters widget's boundaries.
`QEvent::FileOpen` | File open request.
`QEvent::FocusIn` | Widget gains keyboard focus, QFocusEvent.
`QEvent::FocusOut` | Widget loses keyboard focus, QFocusEvent.
`QEvent::FontChange` | Widget's font has changed
`QEvent::Hide` | Widget was hidden, QHideEvent.
`QEvent::HideToParent` | A child widget has been hidden.
`QEvent::IMCompose` | Input method composition is taking place, QIMEvent.
`QEvent::IMEnd` | The end of input method composition, QIMEvent.
`QEvent::IMStart` | The start of input method composition, QIMEvent.
`QEvent::IconTextChange` | Widget's icon text has been changed
`QEvent::KeyPress` | Key press (including Shift, for example), QKeyEvent.
`QEvent::KeyRelease` | Key release, QKeyEvent.
`QEvent::LanguageChange` | The application translation changed, QTranslator
`QEvent::LayoutDirectionChange` | The direction of layouts changed
`QEvent::LayoutRequest` | Widget layout needs to be redone.
`QEvent::Leave` | Mouse leaves widget's boundaries.
`QEvent::LocaleChange` | The system locale changed
`QEvent::MetaCall` |
`QEvent::ModifiedChange` | Widgets modification state has been changed
`QEvent::MouseButtonDblClick` | Mouse press again, QMouseEvent.
`QEvent::MouseButtonPress` | Mouse press, QMouseEvent.
`QEvent::MouseButtonRelease` | Mouse release, QMouseEvent.
`QEvent::MouseMove` | Mouse move, QMouseEvent.
`QEvent::MouseTrackingChange` | The mouse tracking state has changed.
`QEvent::Move` | Widget's position changed, QMoveEvent.
`QEvent::Paint` | Screen update necessary, QPaintEvent.
`QEvent::PaletteChange` | Palette of the widget changed.
`QEvent::Polish` | The widget is polished.
`QEvent::PolishRequest` | The widget should be polished.
`QEvent::Quit` | Reserved.
`QEvent::ParentChange` | Reserved.
`QEvent::Resize` | Widget's size changed, QResizeEvent.
`QEvent::Shortcut` | Key press in child for shortcut key handling, QKeyEvent.
`QEvent::ShortcutOverride` | Key press in child, for overriding shortcut key handling, QKeyEvent.
`QEvent::Show` | Widget was shown on screen, QShowEvent.
`QEvent::ShowFullScreen` | Widget should be shown full-screen (obsolete).
`QEvent::ShowMaximized` | Widget should be shown maximized (obsolete).
`QEvent::ShowMinimized` | Widget should be shown minimized (obsolete).
`QEvent::ShowNormal` | Widget should be shown normally (obsolete).
`QEvent::ShowToParent` | A child widget has been shown.
`QEvent::ShowWindowRequest` | Widget's window should be shown (obsolete).
`QEvent::SockAct` | Socket activated, used to implement QSocketNotifier.
`QEvent::Speech` | Reserved for speech input.
`QEvent::StatusTip` |
`QEvent::StyleChange` | Widget's style has been changed
`QEvent::TabletMove` | A Wacom Tablet Move Event.
`QEvent::TabletPress` | A Wacom Tablet Press Event
`QEvent::TabletRelease` | A Wacom Tablet Release Event
`QEvent::Timer` | Regular timer events, QTimerEvent.
`QEvent::ToolBarSwitch` | The toolbar button is toggled on Mac.
`QEvent::ToolTip` |
`QEvent::UpdateRequest` | The widget should be repainted.
`QEvent::WhatsThis` |
`QEvent::WhatsThisClicked` |
`QEvent::Wheel` | Mouse wheel rolled, QWheelEvent.
`QEvent::WindowActivate` | Window was activated.
`QEvent::WindowBlocked` |
`QEvent::WindowDeactivate` | Window was deactivated.
`QEvent::WindowIconChange` |
`QEvent::WindowStateChange` | The window's state, i.e. minimized, maximized or full-screen, has changed. See QWidget::windowState().
`QEvent::WindowTitleChange` |
`QEvent::WindowUnblocked` |

`QEvent::User` | User-defined event.
`QEvent::MaxUser` | Last user event id.

User events should have values between User and MaxUser inclusive.

## Property Documentation

### accepted : bool

the accept flag of the event object

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.

For convenience, the accept flag can also be set with accept(), and cleared with ignore().

Access functions:

- bool isAccepted () const
- void setAccepted ( bool accepted )

## Member Function Documentation

### QEvent::QEvent ( Type type )

Contructs an event object of type type.

### QEvent::~QEvent () `[virtual]`

Destroys the event. If it was posted, it will be removed from the list of events to be posted.

### void QEvent::accept ()

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

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget.

See also ignore().

### void 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 propgated to the parent widget.

See also accept().

### bool QEvent::spontaneous () const

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

### Type QEvent::type () const

Returns the event type.