QPointingDevice Class

The QPointingDevice class describes a device from which mouse, touch or tablet events originate. More...

Header: #include <QPointingDevice>
CMake: find_package(Qt6 COMPONENTS Gui REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Since: Qt 6.0
Inherits: QInputDevice

Public Types

enum class PointerType { Unknown, Generic, Finger, Pen, Eraser, …, AllPointerTypes }
flags PointerTypes

Public Functions

QPointingDevice(const QString &name, qint64 id, QInputDevice::DeviceType deviceType, QPointingDevice::PointerType pointerType, QInputDevice::Capabilities capabilities, int maxPoints, int buttonCount, const QString &seatName = QString(), QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId(), QObject *parent = nullptr)
QPointingDevice(QObject *parent = nullptr)
int buttonCount() const
int maximumPoints() const
QPointingDevice::PointerType pointerType() const
QPointingDeviceUniqueId uniqueId() const

Static Public Members

const QPointingDevice * primaryPointingDevice(const QString &seatName = QString())

Detailed Description

Each QPointerEvent contains a QPointingDevice pointer to allow accessing device-specific properties like type and capabilities. It is the responsibility of the platform or generic plug-ins to register the available pointing devices via QWindowSystemInterface before generating any pointer events. Applications do not need to instantiate this class, they should just access the global instances pointed to by QPointerEvent::device().

Member Type Documentation

enum class QPointingDevice::PointerTypeflags QPointingDevice::PointerTypes

This enum represents what is interacting with the pointing device.

There is some redundancy between this property and QInputDevice::DeviceType. For example, if a touchscreen is used, then the DeviceType is TouchScreen and PointerType is Finger (always). But on a graphics tablet, it's often possible for both ends of the stylus to be used, and programs need to distinguish them. Therefore the concept is extended so that every QPointerEvent has a PointerType, and it can simplify some event handling code to ignore the DeviceType and react differently depending on the PointerType alone.

Valid values are:

Constant Value Description
QPointingDevice::PointerType::Unknown 0 The pointer type is unknown.
QPointingDevice::PointerType::Generic 0x0001 A mouse or something acting like a mouse (the core pointer on X11).
QPointingDevice::PointerType::Finger 0x0002 The user's finger.
QPointingDevice::PointerType::Pen 0x0004 The drawing end of a stylus.
QPointingDevice::PointerType::Eraser 0x0008 The other end of the stylus (if it has a virtual eraser on the other end).
QPointingDevice::PointerType::Cursor 0x0010 A transparent circle with cross-hairs as found on a Puck device.
QPointingDevice::PointerType::AllPointerTypes 0x7FFF Any of the above (used as a default filter value).

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

Member Function Documentation

QPointingDevice::QPointingDevice(const QString &name, qint64 id, QInputDevice::DeviceType deviceType, QPointingDevice::PointerType pointerType, QInputDevice::Capabilities capabilities, int maxPoints, int buttonCount, const QString &seatName = QString(), QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId(), QObject *parent = nullptr)

Creates a new pointing device instance with the given name, deviceType, pointerType, capabilities, maxPoints, buttonCount, seatName, uniqueId and parent.

QPointingDevice::QPointingDevice(QObject *parent = nullptr)

Creates a new invalid pointing device instance as a child of parent.

int QPointingDevice::buttonCount() const

Returns the maximum number of on-device buttons that can be detected.

Note: Getter function for property buttonCount.

int QPointingDevice::maximumPoints() const

Returns the maximum number of simultaneous touch points (fingers) that can be detected.

Note: Getter function for property maximumPoints.

QPointingDevice::PointerType QPointingDevice::pointerType() const

Returns the pointer type.

Note: Getter function for property pointerType.

[static] const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString &seatName = QString())

Returns the primary pointing device (the core pointer, traditionally assumed to be a mouse) on the given seat seatName.

If multiple pointing devices are registered, this function prefers a mouse or touchpad that matches the given seatName and that does not have another device as its parent. Usually only one master or core device does not have a parent device. But if such a device is not found, this function creates a new virtual "core pointer" mouse. Thus Qt continues to work on platforms that are not yet doing input device discovery and registration.

QPointingDeviceUniqueId QPointingDevice::uniqueId() const

Returns a unique ID (of dubious utility) for the device.

You probably should rather be concerned with QPointerEventPoint::uniqueId().

Note: Getter function for property uniqueId.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.0/qpointingdevice.html