Qt Positioning
The Qt Positioning API provides positioning information via QML and C++ interfaces.
Currently, the API is supported on Android, iOS, macOS, Linux, and Windows (with GPS receivers exposed as a serial port providing NMEA sentences or using Windows.Devices.Geolocation
).
Overview
The Qt Positioning API lets you to determine a position by using a variety of possible sources, including satellite, wifi, or text files. That information can then be used to, for example, determine a position on a map. In addition, you can use to the API to retrieve satellite information and perform area based monitoring.
Using the Module
QML API
The QML types of the module are available through the QtPositioning
import. To use the types, add the following import statement to your .qml file:
import QtPositioning
C++ API
Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.
Building with CMake
Use the find_package()
command to locate the needed module component in the Qt6
package:
find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
For more details, see the Build with CMake overview.
Building with qmake
To configure the module for building with qmake, add the module as a value of the QT
variable in the project's .pro file:
QT += positioning
Permissions
Starting from Qt 6.6, the Qt Positioning module uses new QPermission API to handle location permissions. This means that Qt itself no longer queries for these permissions, so this needs to be done directly from the client application.
Please refer to the Application Permissions page for an example of how to integrate the new QPermission API into the application.
Articles and Guides
- Positioning introduction for C++
- Positioning introduction for QML
- Qt Positioning Plugins
- Interfaces between C++ and QML Code in Qt Positioning
- Qt Positioning on Android
- Qt Positioning on iOS
Examples
Reference
Module Evolution
Changes to Qt Positioning lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.
Licenses
Qt Positioning is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses. Since Qt 5.4, these free software licenses are GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.