Qt Positioning API 凭借 QML 和 C++ 接口提供位置信息。
Currently, the API is supported on
Android
,
iOS
,
macOS
,
Linux
,和
Windows
(with GPS receivers exposed as a serial port providing NMEA sentences or using
Windows.Devices.Geolocation
).
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.
The QML types of the module are available through the
QtPositioning
导入。要使用类型,添加以下 import 语句到 .qml 文件:
import QtPositioning
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 .
使用
find_package()
command to locate the needed module component in the
Qt6
包:
find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
更多细节,见 构建采用 CMake 概述。
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
Changes to Qt Positioning lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.
Qt Positioning 在商业许可下是可用的来自 Qt 公司 。此外,它在自由软件许可下也是可用的。从 Qt 5.4 起,这些自由软件许可是 GNU LGPL (次一般公共许可) 第 3 版 ,或 GNU GPL (一般公共许可) 第 2 版 。见 Qt 许可 进一步了解细节。