O'Reilly logo

Application Development with Qt Creator - Second Edition by Ray Rischpater

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Obtaining a device's position – a simple example

Let's close this chapter with a simple example that returns the device's position, accelerometer, gyroscope, ambient light, and magnetometer readings. Here's how our application looks when running on a Nexus 7:

Obtaining a device's position – a simple example

Note that my Nexus 7 does not have a magnetometer, so these readings aren't being updated.

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):

TEMPLATE = app QT += qml quick positioning sensors SOURCES += main.cpp RESOURCES += qml.qrc # Additional import path used to resolve QML modules in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required