QInputEvent Class

The QInputEvent class is the base class for events that describe user input. More...

Header: #include <QInputEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Inherits: QEvent
Inherited By:

QContextMenuEvent, QKeyEvent, and QPointerEvent

Public Functions

virtual ~QInputEvent() override
const QInputDevice *device() const
QInputDevice::DeviceType deviceType() const
Qt::KeyboardModifiers modifiers() const
quint64 timestamp() const

Reimplemented Public Functions

virtual QInputEvent *clone() const override

Protected Functions

QInputEvent(const QInputEvent &)
QInputEvent(QInputEvent &&)
QInputEvent &operator=(const QInputEvent &other)
QInputEvent &operator=(QInputEvent &&)

Protected Variables

const QInputDevice *m_dev
Qt::KeyboardModifiers m_modState
quint32 m_reserved
quint64 m_timeStamp

Detailed Description

Member Function Documentation

[protected] QInputEvent::QInputEvent(const QInputEvent &)

Default constructs an instance of QInputEvent.

[protected] QInputEvent::QInputEvent(QInputEvent &&)

Move-copy constructor.

[override virtual] QInputEvent::~QInputEvent()

Destroys the instance of QInputEvent. The destructor is virtual.

[override virtual] QInputEvent *QInputEvent::clone() const

[since 6.0] const QInputDevice *QInputEvent::device() const

Returns the source device that generated the original event.

In case of a synthesized event, for example a mouse event that was generated from a touch event, device() continues to return the touchscreen device, so that you can tell that it did not come from an actual mouse. Thus mouseEvent.source()->type() != QInputDevice::DeviceType::Mouse is one possible replacement for the Qt 5 expression mouseEvent.source() == Qt::MouseEventSynthesizedByQt.

This function was introduced in Qt 6.0.

See also QPointerEvent::pointingDevice().

QInputDevice::DeviceType QInputEvent::deviceType() const

Returns the type of device that generated the event.

Qt::KeyboardModifiers QInputEvent::modifiers() const

Returns the keyboard modifier flags that existed immediately before the event occurred.

See also QGuiApplication::keyboardModifiers().

quint64 QInputEvent::timestamp() const

Returns the window system's timestamp for this event. It will normally be in milliseconds since some arbitrary point in time, such as the time when the system was started.

[protected] QInputEvent &QInputEvent::operator=(const QInputEvent &other)

Copy-assignment operator.

[protected] QInputEvent &QInputEvent::operator=(QInputEvent &&)

Move-assignment operator.

Member Variable Documentation

const QInputDevice *QInputEvent::m_dev

Qt::KeyboardModifiers QInputEvent::m_modState

quint32 QInputEvent::m_reserved

quint64 QInputEvent::m_timeStamp

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.