QPointingDevice 类

QPointingDevice 类描述发源鼠标、触摸或数位板事件的设备。 更多...

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

公共类型

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

公共函数

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

信号

void grabChanged (QObject * grabber , QPointingDevice::GrabTransition transition , const QPointerEvent * event , const QEventPoint & point ) const

静态公共成员

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

详细描述

每个 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 ().

成员类型文档编制

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 () 信号。

Valid values are:

常量 描述
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:

常量 描述
QPointingDevice::PointerType::Unknown 0 指针类型未知。
QPointingDevice::PointerType::Generic 0x0001 A mouse or something acting like a mouse (the core pointer on X11).
QPointingDevice::PointerType::Finger 0x0002 用户的手指。
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 设备。
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.

成员函数文档编制

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)

创建新的指向设备实例采用给定 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.

注意: getter 函数对于特性 buttonCount。

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

此信号发射当 grabber object gains or loses an exclusive or passive grab of point during delivery of event transition tells what happened, from the perspective of the grabber 对象。

注意: 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 .

另请参阅 QPointerEvent::setExclusiveGrabber (), QPointerEvent::addPassiveGrabber (),和 QPointerEvent::removePassiveGrabber ().

int QPointingDevice:: maximumPoints () const

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

注意: Getter function for property maximumPoints.

QPointingDevice::PointerType QPointingDevice:: pointerType () const

返回指针类型。

注意: getter 函数对于特性 pointerType。

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

返回首要指向设备 (核心指针,传统假定为鼠标) 按给定座位 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().

注意: Getter function for property uniqueId.