QOrientationReading

Since: 1.0

#include <QtSensors/QOrientationReading>

QtSensors

The QOrientationReading class represents one reading from the orientation sensor.

The orientation sensor reports the orientation of the device. As it operates below the UI level it does not report on or even know how the UI is rotated. Most importantly this means that this sensor cannot be used to detect if a device is in portrait or landscape mode.

This sensor is useful to detect that a particular side of the device is pointing up.


Overview

Inheritance

QSensorReading
QOrientationReading

Public Types Index

enum Orientation

Undefined = 0, TopUp, TopDown, LeftUp, RightUp, FaceUp, FaceDown

Properties Index

Orientationorientation [read-only]
QtMobility::qtimestamptimestamp [read-only]Inherited

Public Functions Index

Orientationorientation () const
voidsetOrientation (Orientation orientation)
voidsetTimestamp (qtimestamp timestamp)Inherited
qtimestamptimestamp () const Inherited
QVariantvalue (int index) const Inherited
intvalueCount () const Inherited

Protected Functions Index

Only has inherited protected functions

virtual voidcopyValuesFrom (QSensorReading *other)Inherited
QScopedPointer< QSensorReadingPrivate > *d_ptr ()Inherited
QSensorReading (QObject *parent, QSensorReadingPrivate *d)Inherited

Public Types

Orientation

This enum represents the orientation of the device.

To explain the meaning of each value it is helpful to refer to the following diagram.

The orientations are shown here in order: TopUp, TopDown, LeftUp, RightUp, FaceUp, FaceDown.

Undefined The orientation is unknown. TopUp The Top edge of the device is pointing up. TopDown The Top edge of the device is pointing down. LeftUp The Left edge of the device is pointing up. RightUp The Right edge of the device is pointing up. FaceUp The Face of the device is pointing up. FaceDown The Face of the device is pointing down.

It should be noted that the orientation sensor reports the orientation of the device and not the UI. The orientation of the device will not change just because the UI is rotated. This means this sensor cannot be used to detect if a device is in portrait or landscape mode.

Undefined = 0
TopUp
TopDown
LeftUp
RightUp
FaceUp
FaceDown

Properties

Orientation orientation[read-only]

the orientation of the device.

The unit is an enumeration describing the orientation of the device.

See also:

{QOrientationReading Units}

Since:

1.0

QtMobility::qtimestamp timestampInherited[read-only]

the timestamp of the reading.

Returns the timestamp of the reading.

See also:

qtimestamp

Since:

1.0

,

1.0

Public Functions

Orientation orientation ()

void setOrientation (

Sets the orientation for the reading.

Since:

1.0

void setTimestamp (Inherited

Sets the timestamp of the reading.

Since:

1.0

qtimestamp timestamp ()Inherited

QVariant value (
  • intindex)
Inherited

Returns the value of the property at index.

Note that this function is slower than calling the data function directly.

Here is an example of getting a property via the different mechanisms available.

Accessing directly provides the best performance but requires compile-time knowledge of the data you are accessing.

QAccelerometerReading *reading = ...;
qreal x = reading->x();

You can also access a property by name. To do this you must call QObject::property().

qreal x = reading->property("x").value<qreal>();

Finally, you can access values via numeric index.

qreal x = reading->value(0).value<qreal>();

Note that value() can only access properties declared with Q_PROPERTY() in sub-classes of QSensorReading.

See also:

valueCount(), QObject::property()

Since:

1.0

int valueCount ()Inherited

Returns the number of extra properties that the reading has.

Note that this does not count properties declared in QSensorReading.

As an example, this returns 3 for QAccelerometerReading because there are 3 properties defined in that class.
Since:

1.0

Protected Functions

(Only has inherited protected functions)

virtual void copyValuesFrom (Inherited

QScopedPointer< QSensorReadingPrivate > * d_ptr ()Inherited

QSensorReading (
  • QObject *parent,
  • QSensorReadingPrivate *d )
Inherited

Last modified: 2014-03-13

comments powered by Disqus