Qt Positioning 插件
Qt Positioning 的大部分功能都是通过插件实现的。本文档概述了如何开发新的定位插件。
默认插件
Qt 已随附了一些插件。它们是
安卓 | 封装Android定位子系统。仅在 Android 上可用。 |
corelocation | 封装 iOS 和 macOS 定位子系统。仅适用于支持 corelocation 的苹果平台。 |
geoclue2 | GeoClue v2后端,为 GeoClue v2 D-Bus 服务提供接口。 |
gypsy | Gypsy后端,为 Gypsy 守护进程提供接口。 |
winrt | 封装 WinRT 定位子系统。仅适用于 WinRT 和 Windows10。 |
nmea | NMEA后端可解析来自 GPS 接收机的 NMEA 数据流以提供位置更新。该插件可使用串口、套接字或文件作为源。 |
positionpoll | 仅通过位置更新轮询提供区域监控功能的后端。 |
插件描述
每个插件都由一个 json 文件描述。json 文件描述了插件的功能和版本。下面是 postionpoll 插件使用的 json 文件示例:
{ "Keys": ["positionpoll"], "Provider": "positionpoll", "Position": false, "Satellite": false, "Monitor": true, "Priority": 1000, "Testable": true }
条目含义如下:
关键字 | 说明 |
---|---|
关键字 | 插件的唯一名称/关键字。每个定位插件都必须有一个唯一的名称。 |
提供商 | 服务提供商名称。多个插件可能具有相同的名称。在这种情况下,将使用版本字符串来进一步区分插件。 |
位置 | 如果插件实现了QGeoPositionInfoSource ,则设置为true 。 |
卫星 | 如果插件实现了QGeoSatelliteInfoSource ,则设置为true 。 |
监视器 | 如果插件实现了QGeoAreaMonitorSource ,则设置为true 。 |
优先级 | 插件的优先级。如果多个插件具有相同的提供者名称,将使用优先级最高的插件。 |
实现插件
插件实现者需要子类化QGeoPositionInfoSourceFactory 并覆盖其一个或多个函数。如果插件不支持特定功能,函数应返回 0 或使用默认实现。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.