SatelliteSource QML Type

SatelliteSource 类提供卫星信息。更多

Import Statement: import QtPositioning
Since: Qt 6.5

属性

方法

详细说明

SatelliteSource 类提供有关使用中的卫星和视图中的卫星的信息。该类是QGeoSatelliteInfoSource 的 QML 表示。

与 C++ 对应类一样,该类支持不同的插件。使用name 属性指定要使用的插件名称,并在需要时提供PluginParameters。如果未设置name 属性,将使用默认插件。有关可用插件的更多信息,请参阅Qt Positioning Plugins

使用valid 属性检查 SatelliteSource 状态。

使用updateInterval 属性指示应用程序希望接收卫星信息更新的频率。start()、stop() 和update() 方法以及active 属性可用于控制 SatelliteSource 的运行,设置 属性相当于调用start() 或stop()。

当 SatelliteSource 处于活动状态时,可使用satellitesInViewsatellitesInUse 属性检索卫星信息更新。

如果在卫星信息更新过程中发生错误,可使用sourceError 属性获取实际错误代码。

使用示例

下面的示例显示了一个 SatelliteSource,它使用NMEA插件每秒接收卫星信息更新,并将视图中的卫星数量和使用中的卫星数量打印到控制台。

SatelliteSource {
    id: source
    name: "nmea"
    active: true
    updateInterval: 1000
    PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }

    onSatellitesInUseChanged: {
        console.log("Satellites in use:", source.satellitesInUse.length)
    }
    onSatellitesInViewChanged: {
        console.log("Satellites in view:", source.satellitesInView.length)
    }
}

另请参阅 QGeoSatelliteInfoSource,PluginParameter, 和geoSatelliteInfo

属性文档

active : bool

此属性表示卫星源是否处于活动状态。将此属性设置为false 等于调用stop ,将此属性设置为true 等于调用start

另请参阅 start,stop, 和update


name : string

该属性包含当前提供卫星信息的插件的唯一内部名称。

设置该属性会使SatelliteSource 使用特定的后端插件。如果在更改 name 属性时,SatelliteSource 处于活动状态,它将变为非活动状态。如果无法加载指定的后端,卫星源将失效。

更改名称属性可能会导致updateInterval 属性也发生变化。


parameters : list<PluginParameter> [default]

该属性包含插件参数列表。

另请参阅 PluginParameter


satellitesInUse : list<geoSatelliteInfo> [read-only]

该属性包含当前正在使用的卫星列表。这些卫星用于获取 "定点",即用于确定当前位置的卫星。


satellitesInView : list<geoSatelliteInfo> [read-only]

该属性包含当前视图中的卫星列表。


sourceError : enumeration [read-only]

.AccessError(访问错误) - 该属性显示后端数据提供程序最后出现的错误。

  • SatelliteSource.AccessError - 由于应用程序缺乏所需的权限,与卫星后端的连接设置失败。
  • SatelliteSource.ClosedError - 卫星后端关闭了连接,例如在用户将定位服务切换为关闭的情况下。
  • SatelliteSourceNoError.- 未发生错误。
  • SatelliteSource.UnknownSourceError - 出现不明错误。
  • SatelliteSource.UpdateTimeoutError - 在指定的超时时间内无法检索到卫星信息。

updateInterval : int

该属性表示以毫秒为单位的所需更新间隔。


valid : bool [read-only]

如果SatelliteSource 对象已获得有效的后端插件以提供数据,则该属性为true ,否则为false

应用程序应检查该属性,以确定运行时平台是否可用并启用了卫星信息,并做出相应反应。


方法文档

var backendProperty(string name)

如果存在,则返回名为name 的后端特定属性的值。否则,包括在未初始化的SatelliteSource 上调用时,返回值将无效。

另请参阅 setBackendProperty().


bool setBackendProperty(string name, var value)

将名为name 的后端特定属性设置为value 。成功时返回 true,否则返回 false,包括在未初始化的SatelliteSource 上调用时。

另请参阅 backendProperty()。


start()

从卫星源请求更新。如果已设置,则使用updateInterval ,否则使用默认间隔。如果没有可用的源,则此方法无效。

另请参阅 stop,update, 和active


stop()

停止更新卫星信号源。如果没有可用信息源或信息源未激活,则此方法无效。

另请参阅 start,update, 和active


update(int timeout = 0)

从卫星信号源请求单次更新的便捷方法。如果没有可用的源,此方法无效。

如果卫星信号源未激活,则在接收更新或请求超时之前,卫星信号源将一直处于激活状态。请求超时时间取决于插件。

timeout 的单位是毫秒。如果timeout 为零(默认值),则默认为适合源的合理超时时间。

另请参阅 start,stop, 和active


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