QTapReading Class

The QTapReading class represents one reading from the tap sensor. 更多...

头文件: #include <QTapReading>
qmake: QT += sensors
开始支持版本: Qt 5.1
基类: QSensorReading

公有类型

enum TapDirection { Undefined, X, Y, Z, ..., Z_Both }

属性

公有函数

bool isDoubleTap() const
void setDoubleTap(bool doubleTap)
void setTapDirection(TapDirection tapDirection)
TapDirection tapDirection() const

其他继承的成员

  • 1 个公有槽函数继承自 QObject
  • 2 个信号继承自 QObject
  • 1 个公有变量继承自 QObject
  • 10 个静态公有成员继承自 QObject
  • 9 个受保护的函数继承自 QObject
  • 2 个受保护的变量继承自 QObject

详细描述

The QTapReading class represents one reading from the tap sensor.

QTapReading Units

The tap sensor registers tap events along the 3 axes that originate from the phone. The axes are arranged as follows.

By default it returns only double tap events. The QTapSensor::returnDoubleTapEvents property must be set to false to return individual tap events.

成员类型

enum QTapReading::TapDirection

The tap direction is indicated using flags. Applications should check for the presence of a particular flag as multiple flags may be set at once.

The X, Y and Z flags allow an app to check for taps along an axis without caring about the direction.


  if (reading->tapDirection()&QTapReading::X) {
      ...
  }

The *_Pos and *_Neg flags allow checking for taps in a specific direction. Note that some devices cannot determine the direction of a tap and will set both the _Pos and _Neg flag for the detected axis. Previous versions of the API did not allow this. Applications that check for the _Pos and _Neg flags as values should be updated so they can work with all devices.

For example, if you have code like


  if (reading->tapDirection() == QTapReading::X_Pos) {
      ...
  }

you can rewrite it as


  if (reading->tapDirection()&QTapReading::X_Pos) {
      ...
  }

ConstantValueDescription
QTapReading::Undefined0This value means that the direction is unknown.
QTapReading::X0x0001This flag is set if the tap was along the X axis.
QTapReading::Y0x0002This flag is set if the tap was along the Y axis.
QTapReading::Z0x0004This flag is set if the tap was along the Z axis.
QTapReading::X_Pos0x0011This flag is set if the tap was towards the positive X direction.
QTapReading::Y_Pos0x0022This flag is set if the tap was towards the positive Y direction.
QTapReading::Z_Pos0x0044This flag is set if the tap was towards the positive Z direction.
QTapReading::X_Neg0x0101This flag is set if the tap was towards the negative X direction.
QTapReading::Y_Neg0x0202This flag is set if the tap was towards the negative Y direction.
QTapReading::Z_Neg0x0404This flag is set if the tap was towards the negative Z direction.
QTapReading::X_Both0x0111Equivalent to X_Pos|X_Neg. Returned by devices that cannot detect the direction of a tap.
QTapReading::Y_Both0x0222Equivalent to Y_Pos|Y_Neg. Returned by devices that cannot detect the direction of a tap.
QTapReading::Z_Both0x0444Equivalent to Z_Pos|Z_Neg. Returned by devices that cannot detect the direction of a tap.

属性

doubleTap : const bool

This property holds a value indicating if there was a single or double tap.

  • true - double tap
  • false - single tap

访问函数:

bool isDoubleTap() const

参见 QTapReading Units.

tapDirection : const TapDirection

This property holds the direction of the tap.

访问函数:

TapDirection tapDirection() const

参见 QTapReading Units.

成员函数

void QTapReading::setDoubleTap(bool doubleTap)

Sets the double tap status of the reading to doubleTap.

参见 isDoubleTap().

void QTapReading::setTapDirection(TapDirection tapDirection)

Sets the tap direction to tapDirection.

参见 tapDirection().