本页内容

Qt Positioning Gypsy 插件

概述

该插件是连接Gypsy 守护进程的接口。它需要系统中已安装并正在运行该守护进程才能正常工作。

该插件使用 D-Bus 和 GLib 连接 GPS 设备并提供卫星信息。

目前该插件不提供定位信息。

可通过提供程序名称gypsy 加载该插件。

参数

下表列出了可传递给 gypsy 插件的参数。

参数描述
deviceName将用于提供卫星信息的设备名称(或设备文件的路径)。典型值可以是/dev/ttyUSB0 或/dev/ttyACM0 。
gconfKey用于从 GConf 配置系统中提取设备名称的键。

该插件支持两种指定设备名称的方式:

  • 通过deviceName插件参数直接指定设备名称。
  • 使用gconfKey插件参数指定配置键,并从 GConf 配置系统中提取设备名称。当设备名称已在其他基于 GConf 的应用程序中指定时,此方法非常有用。

默认情况下,若未指定任何参数,插件将尝试使用以下硬编码键从 GConf 配置系统中提取设备名称:

/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice

使用 GConf 设置参数

要为 GConf 配置系统中的某个键指定值,请按以下方式使用gconftool-2:

gconftool-2 -t string -s /apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice /dev/ttyUSB0

示例

以下示例演示了如何使用 C++ 创建一个gypsy卫星信息源。

直接指定设备名称:

QVariantMap parameters;
parameters["deviceName"] = "/dev/ttyACM0";
QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createSource("gypsy", parameters, this);

使用 GConf 键:

QVariantMap parameters;
parameters["gconfKey"] = "/apps/myapp/mykey";
QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createSource("gypsy", parameters, this);

© 2026 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.