Obtaining a device's position

Let's move on to a simple example that returns the device's position, accelerometer, gyroscope, ambient light, and magnetometer readings. Here's what our application looks like when running on a Huawei phone:

Note that my Huawei phone does not have a magnetometer, so these readings aren't being updated. Let's see how this works:

  1. First, we need to ensure that we include the positioning and sensor modules in our .pro file (if we don't, the application will compile but fail to launch):
QT += quick positioning sensors 
  1. Next, we'll move on to the QML itself. This is long but straightforward. First, we add the necessary ...

Get Application Development with Qt Creator now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.