Qt Simulator Manual

Simulating Sensors

Mobile devices contain built-in sensors, such as an accelerometer, a compass, and ambient light or proximity sensors. The availability of sensors depends on the device model.

The following types of interaction can be enabled by using the sensors on the device:

  • Changing application settings based on the ambient light conditions, such as bright sunshine or night time.
  • Changing the screen orientation on the device from portrait to landscape as the device is rotated.
  • Silencing an incoming call when the device orientation is changed (for example, on a table) from screen down to screen up and back again.
  • Allowing movement gestures, such as device rotation, to trigger an action.
  • In a map application, changing the orientation of a map based on the device compass orientation.
  • Triggering an action when the device comes in close proximity to the user's hand or head.

You can test applications that use the Qt Mobility Sensors API in the Qt Simulator. The Sensors section contains controls to set the values the sensors currently return.

"Sensors section"

Changing Light Conditions

Specify the ambient light state in the Ambient light field.

Device Movement

The accelerometer sensor channel detects movement gestures, such as moving a mobile device up or down. The three-dimensional Cartesian coordinate system is used to illustrate direction of the acceleration, as shown in the figure below. The x and y axes define a plane where z-axis direction is perpendicular to the xy plane. When a device moves along an axis in the positive direction, the acceleration is positive. When the device moves in the negative direction, the acceleration is negative. For example, when a device moves along the x-axis to the direction of -x, the acceleration is negative.

"Acceleration"

A mobile device placed screen up on a desk experiences a force of approximately 9.8 on the z axis (that is, upwards). This is the proper acceleration the device experiences relative to freefall.

To simulate movement of the device:

  • Click or right-click the image of the device in the Accelerometer field and hold down the mouse button to rotate the image.
  • Click the rotation buttons buttons to rotate the image:

    "Rotation buttons in Sensors view"

  • Use the sliders to specify values for the x, y, and z axis in the Accelerometer x, Accelerometer y, and Accelerometer z fields.

Device Rotation

The rotation sensor channel uses three angles, measured in degrees to define the orientation of the device in three-dimensional space. These angles are defined using right hand rotation with axes as defined by the right hand cartesian coordinate system.

"Rotation"

Click or right-click the image of the device in the Accelerometer field and hold down the mouse button to apply the angles to the device. You can also click the rotation buttons. This allows you to test how the application handles the interaction related to rotating the device.

For more information about how the angles are applied, see QRotationReading Units.

Compass Orientation

The compass returns the azimuth of the device as degrees from magnetic north in a clockwise direction based on the top of the device.

Note: The top of the device is a fixed point and may not represent the orientation that the user is holding the device in.

The calibration status of the device must be accurate for the azimuth to be accurate. It takes some time to calibrate the magnetic north sensor and, even after being calibrated, it can become uncalibrated. So, for an application to be sure the data coming from the magnetic north sensor channel is accurate, it must monitor changes in the calibration property and inform the user if something needs to be done to recalibrate the sensor.

Use sliders to set the Compass calibration level and Compass azimuth values.

Proximity

Proximity indicates how far away from the device the user is. Use the button to toggle between Near and Far distance.

Using a Fixed Timestamp

Many sensors update frequently, and therefore sensor readings done by the client application contain a fresh timestamp by default. To disable that and provide a fixed timestamp manually, select the Override radio button in the Timestamp group and specify a date and time.

[Previous: Simulating Messaging] [Next: Importing Calendar Events]

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

s.parentNode.insertBefore(ga, s); })(); -->