QEventPoint Class

The QEventPoint class provides information about a point in a QPointerEvent. More...

Header: #include <QEventPoint>
CMake: find_package(Qt6 COMPONENT Gui)
target_link_libraries(mytarget PUBLIC Qt::Gui)
qmake: QT += gui
Since: Qt 6.0

Public Types

enum State { Unknown, Stationary, Pressed, Updated, Released }
flags States

Public Functions

QEventPoint(QEventPoint &&other)
QEventPoint(const QEventPoint &other)
QEventPoint(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)
QEventPoint &operator=(QEventPoint &&other)
QEventPoint &operator=(const QEventPoint &other)
~QEventPoint()
QSizeF ellipseDiameters() const
QPointF globalPosition() const
QPointF globalPressPosition() const
int id() const
QPointF lastPosition() const
ulong lastTimestamp() const
QPointF position() const
QPointF pressPosition() const
qreal pressure() const
qreal rotation() const
QPointF sceneLastPosition() const
QPointF scenePosition() const
QPointF scenePressPosition() const
void setAccepted(bool accepted = true)
QEventPoint::State state() const
qreal timeHeld() const
ulong timestamp() const
QPointingDeviceUniqueId uniqueId() const
QVector2D velocity() const
bool operator!=(const QEventPoint &other) const
bool operator==(const QEventPoint &other) const

Detailed Description

Member Type Documentation

enum QEventPoint::State
flags QEventPoint::States

Specifies the state of this event point.

ConstantValueDescription
QEventPoint::UnknownQt::TouchPointUnknownStateUnknown state.
QEventPoint::StationaryQt::TouchPointStationaryThe event point did not move.
QEventPoint::PressedQt::TouchPointPressedThe touch point or button is pressed.
QEventPoint::UpdatedQt::TouchPointMovedThe event point was updated.
QEventPoint::ReleasedQt::TouchPointReleasedThe touch point or button was released.

The States type is a typedef for QFlags<State>. It stores an OR combination of State values.

Member Function Documentation

QEventPoint::QEventPoint(QEventPoint &&other)

Constructs an event point by moving other.

QEventPoint::QEventPoint(const QEventPoint &other)

Constructs an event point by making a shallow copy of other.

QEventPoint::QEventPoint(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)

Constructs an event point with the given pointId, state, scenePosition and globalPosition.

QEventPoint &QEventPoint::operator=(QEventPoint &&other)

Move-assigns other to this event point instance.

QEventPoint &QEventPoint::operator=(const QEventPoint &other)

Assigns other to this event point and returns a reference to this event point.

QEventPoint::~QEventPoint()

Destroys the event point.

QSizeF QEventPoint::ellipseDiameters() const

Returns the width and height of the bounding ellipse of the touch point. The return value is in logical pixels. Most touchscreens do not detect the shape of the contact point, and no mice or tablet devices can detect it, so a null size is the most common value. On some touchscreens the diameters may be nonzero and always equal (the ellipse is approximated as a circle).

Note: Getter function for property ellipseDiameters.

QPointF QEventPoint::globalPosition() const

Returns the position of this point on the screen or virtual desktop.

Note: Getter function for property globalPosition.

See also globalPressPosition(), position(), and scenePosition().

QPointF QEventPoint::globalPressPosition() const

Returns the position at which this point was pressed on the screen or virtual desktop.

See also globalPosition(), pressPosition(), and scenePressPosition().

int QEventPoint::id() const

Returns the ID number of this event point.

Note: Do not assume that ID numbers start at zero or that they are sequential. Such an assumption is often false due to the way the underlying drivers work.

Note: Getter function for property id.

QPointF QEventPoint::lastPosition() const

Returns the position of this point from the previous press or move event, relative to the widget or QGraphicsItem that received the event.

See also position() and pressPosition().

ulong QEventPoint::lastTimestamp() const

Returns the time from the previous QPointerEvent that contained this point.

See also globalLastPosition().

QPointF QEventPoint::position() const

Returns the position of this point, relative to the widget or item that received the event.

Note: Getter function for property position.

QPointF QEventPoint::pressPosition() const

Returns the position at which this point was pressed, relative to the widget or item that received the event.

See also position().

qreal QEventPoint::pressure() const

Returns the pressure of this point. The return value is in the range 0.0 to 1.0.

Note: Getter function for property pressure.

qreal QEventPoint::rotation() const

Returns the angular orientation of this point. The return value is in degrees, where zero (the default) indicates the finger, token or stylus is pointing upwards, a negative angle means it's rotated to the left, and a positive angle means it's rotated to the right. Most touchscreens do not detect rotation, so zero is the most common value.

Note: Getter function for property rotation.

QPointF QEventPoint::sceneLastPosition() const

Returns the scene position of this point from the previous press or move event.

The scene position is the position in QGraphicsScene coordinates if the QTouchEvent is handled by a QGraphicsItem::touchEvent() reimplementation, and identical to the screen position for widgets.

See also scenePosition() and scenePressPosition().

QPointF QEventPoint::scenePosition() const

Returns the position of this point relative to the window or scene.

The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(), in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(), or the window position in widget applications.

Note: Getter function for property scenePosition.

See also scenePressPosition(), position(), and globalPosition().

QPointF QEventPoint::scenePressPosition() const

Returns the scene position at which this point was pressed.

The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(), in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(), or the window position in widget applications.

See also scenePosition(), pressPosition(), and globalPressPosition().

void QEventPoint::setAccepted(bool accepted = true)

Sets the accepted state of the point to accepted.

In widget-based applications, this function is not used so far, because it's only meaningful for a widget to accept or reject a complete QInputEvent.

In Qt Quick however, it's normal for an Item or Event Handler to accept only the individual points in a QTouchEvent that are actually participating in a gesture, while other points can be delivered to other items or handlers. For the sake of consistency, that applies to any QPointerEvent; and delivery is done only when all points in a QPointerEvent have been accepted.

See also QEvent::setAccepted().

QEventPoint::State QEventPoint::state() const

Returns the current state of this point.

Note: Getter function for property state.

ulong QEventPoint::timestamp() const

Returns the most recent time at which this point was included in a QPointerEvent.

Note: Getter function for property timestamp.

See also QPointerEvent::timestamp().

QPointingDeviceUniqueId QEventPoint::uniqueId() const

Returns the unique ID of this point or token, if any.

It is often invalid (see isValid()), because touchscreens cannot uniquely identify fingers.

When it comes from a QTabletEvent, it identifies the serial number of the stylus in use.

It may identify a specific token (fiducial object) when the TUIO driver is in use with a touchscreen that supports them.

Note: Getter function for property uniqueId.

QVector2D QEventPoint::velocity() const

Returns a velocity vector, in units of pixels per second, in the coordinate system of the screen or desktop.

Note: If the device's capabilities include QInputDevice::Velocity, it means velocity comes from the operating system (perhaps the touch hardware or driver provides it). But usually the Velocity capability is not set, indicating that the velocity is calculated by Qt, using a simple Kalman filter to provide a smoothed average velocity rather than an instantaneous value. Effectively it tells how fast and in what direction the user has been dragging this point over the last few events, with the most recent event having the strongest influence.

Note: Getter function for property velocity.

See also QInputDevice::capabilities() and QInputEvent::device().

bool QEventPoint::operator!=(const QEventPoint &other) const

Returns true if this event point is not equal to other, otherwise return false.

bool QEventPoint::operator==(const QEventPoint &other) const

Returns true if this event point is equal to other, otherwise return false.