- Qt 6.10
- Qt GUI
- C++ Classes
- QPointingDevice
- Qt 6.10.2 Reference Documentation

# QPointingDevice Class

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

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

- List of all members, including inherited members
- QPointingDevice is part of Event Classes.

## Public Types

enum | GrabTransition { GrabExclusive, UngrabExclusive, CancelGrabExclusive, GrabPassive, UngrabPassive, …, OverrideGrabPassive }
enum class | PointerType { Unknown, Generic, Finger, Pen, Eraser, …, AllPointerTypes }
flags | PointerTypes

## Public Functions

| QPointingDevice(QObject *parent = nullptr)
| 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)
int | buttonCount() const
int | maximumPoints() const
QPointingDevice::PointerType | pointerType() const
QPointingDeviceUniqueId | uniqueId() const

## Signals

void | grabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point) 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 QPointingDevice::GrabTransition

This enum represents a transition of exclusive or passive grab from one object (possibly `nullptr`) to another (possibly `nullptr`). It is emitted as an argument of the QPointingDevice::grabChanged() signal.

Valid values are:

Constant | Value | Description
--- | --- | ---
`QPointingDevice::GrabExclusive` | `0x10` | Emitted after QPointerEvent::setExclusiveGrabber().
`QPointingDevice::UngrabExclusive` | `0x20` | Emitted after QPointerEvent::setExclusiveGrabber() when the grabber is set to `nullptr`, to notify that the grab has terminated normally.
`QPointingDevice::CancelGrabExclusive` | `0x30` | Emitted after QPointerEvent::setExclusiveGrabber() when the grabber is set to a different object, to notify that the old grabber's grab is "stolen".
`QPointingDevice::GrabPassive` | `0x01` | Emitted after QPointerEvent::addPassiveGrabber().
`QPointingDevice::UngrabPassive` | `0x02` | Emitted when a passive grab is terminated normally, for example after QPointerEvent::removePassiveGrabber().
`QPointingDevice::CancelGrabPassive` | `0x03` | Emitted when a passive grab is terminated abnormally (a gesture is canceled).
`QPointingDevice::OverrideGrabPassive` | `0x04` | This value is not currently used.

### enum class QPointingDevice::PointerType
flags 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(QObject *parent = nullptr)

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

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

### int QPointingDevice::buttonCount() const

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

Note: Getter function for property buttonCount.

### `[signal]` void QPointingDevice::grabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point) const

This signal is emitted when the grabber object gains or loses an exclusive or passive grab of point during delivery of event. The transition tells what happened, from the perspective of the `grabber` object.

Note: A grab transition from one object to another results in two signals, to notify that one object has lost its grab, and to notify that there is another grabber. In other cases, when transitioning to or from a non-grabbing state, only one signal is emitted: the grabber argument is never `nullptr`.

See also QPointerEvent::setExclusiveGrabber(), QPointerEvent::addPassiveGrabber(), and QPointerEvent::removePassiveGrabber().

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