QTouchDevice Class

The QTouchDevice class describes the device from which touch events originate. 更多...

头: #include <QTouchDevice>
qmake: QT += gui
Since: Qt 5.0

公共类型

flags Capabilities
enum CapabilityFlag { Position, Area, Pressure, Velocity, ..., MouseEmulation }
enum DeviceType { TouchScreen, TouchPad }

公共函数

QTouchDevice ()
~QTouchDevice ()
QTouchDevice::Capabilities capabilities () const
int maximumTouchPoints () const
QString name () const
void setCapabilities (QTouchDevice::Capabilities caps )
void setMaximumTouchPoints (int max )
void setName (const QString & name )
void setType (QTouchDevice::DeviceType devType )
QTouchDevice::DeviceType type () const

静态公共成员

QList<const QTouchDevice *> devices ()
const QMetaObject staticMetaObject

详细描述

The QTouchDevice class describes the device from which touch events originate.

每个 QTouchEvent 包含 QTouchDevice 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 touch devices via QWindowSystemInterface before generating any touch events. Applications do not need to instantiate this class, they should just access the global instances pointed to by QTouchEvent::device ().

成员类型文档编制

enum QTouchDevice:: CapabilityFlag
flags QTouchDevice:: Capabilities

此枚举用于 QTouchDevice::capabilities () to indicate what kind of information the touch device or its driver can provide.

常量 描述
QTouchDevice::Position 0x0001 Indicates that position information is available, meaning that the pos() family of functions in the touch points return valid points.
QTouchDevice::Area 0x0002 Indicates that touch area information is available, meaning that the rect() family of functions in the touch points return valid rectangles.
QTouchDevice::Pressure 0x0004 Indicates that pressure information is available, meaning that pressure() returns a valid value.
QTouchDevice::Velocity 0x0008 Indicates that velocity information is available, meaning that velocity() returns a valid vector.
QTouchDevice::RawPositions 0x0010 Indicates that the list returned by QTouchEvent::TouchPoint::rawScreenPositions () may contain one or more positions for each touch point. This is relevant when the touch input gets filtered or corrected on driver level.
QTouchDevice::NormalizedPosition 0x0020 Indicates that the normalized position is available, meaning that normalizedPos() returns a valid value.
QTouchDevice::MouseEmulation 0x0040 Indicates that the device synthesizes mouse events. This enum value has been introduced in Qt 5.5.

Capabilities 类型是 typedef 对于 QFlags <CapabilityFlag>. It stores an OR combination of CapabilityFlag values.

enum QTouchDevice:: DeviceType

This enum represents the type of device that generated a QTouchEvent .

常量 描述
QTouchDevice::TouchScreen 0 In this type of device, the touch surface and display are integrated. This means the surface and display typically have the same size, such that there is a direct relationship between the touch points' physical positions and the coordinate reported by QTouchEvent::TouchPoint . As a result, Qt allows the user to interact directly with multiple QWidgets and QGraphicsItems at the same time.
QTouchDevice::TouchPad 1 In this type of device, the touch surface is separate from the display. There is not a direct relationship between the physical touch location and the on-screen coordinates. Instead, they are calculated relative to the current mouse position, and the user must use the touch-pad to move this reference point. Unlike touch-screens, Qt allows users to only interact with a single QWidget or QGraphicsItem at a time.

成员函数文档编制

QTouchDevice:: QTouchDevice ()

Creates a new touch device instance. By default the name is empty, the only capability is Position and type is TouchScreen .

QTouchDevice:: ~QTouchDevice ()

Destroys a touch device instance.

QTouchDevice::Capabilities QTouchDevice:: capabilities () const

Returns the touch device capabilities.

另请参阅 setCapabilities ().

[static] QList <const QTouchDevice *> QTouchDevice:: devices ()

Returns a list of all registered devices.

注意: The returned list cannot be used to add new devices. To add a simulated touch screen for an autotest, QTest::createTouchDevice () can be used. To add real touch screens to QPA plugins, the private QWindowSystemInterface::registerTouchDevice() function can be used.

int QTouchDevice:: maximumTouchPoints () const

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

该函数在 Qt 5.2 引入。

另请参阅 setMaximumTouchPoints ().

QString QTouchDevice:: name () const

Returns the touch device name.

This string may often be empty. It is however useful for systems that have more than one touch input device because there it can be used to differentiate between the devices (i.e. to tell from which device a QTouchEvent originates from).

另请参阅 setName ().

void QTouchDevice:: setCapabilities ( QTouchDevice::Capabilities caps )

Sets the capabilities caps supported by the device and its driver.

另请参阅 capabilities ().

void QTouchDevice:: setMaximumTouchPoints ( int max )

Sets the maximum number of simultaneous touchpoints max supported by the device and its driver.

另请参阅 maximumTouchPoints ().

void QTouchDevice:: setName (const QString & name )

设置 name (a unique identifier) for the device. In most systems it is enough to leave this unset and keep the default empty name. This identifier becomes important when having multiple touch devices and a need to differentiate between them.

另请参阅 name ().

void QTouchDevice:: setType ( QTouchDevice::DeviceType devType )

Sets the device type devType .

另请参阅 type ().

QTouchDevice::DeviceType QTouchDevice:: type () const

Returns the touch device type.

另请参阅 setType ().