本页内容

routeSegment QML Type

routeSegment 类型表示 Route 中的一个路段。更多内容...

Import Statement: import QtLocation 6.12
Since: QtLocation 5.5

属性

详细说明

一个 routeSegment 实例包含有关该路段物理布局的信息、路段的长度、穿越该路段所需的预计时间,以及与该路段终点相关联的可选routeManeuver实例。

可以将 routeSegment 实例视为路由图上的边,而routeManeuver 实例则是附加在图的顶点上的可选标签。

获取 Route 对象的主要途径是通过 Routes 中的RouteModel 。

示例

以下 QML 代码片段演示了如何打印路线段的相关信息:

import QtQuick
import QtPositioning
import QtLocation

Text {
    text: "Segment distance " + routeSegment.distance + " meters, " + routeSegment.path.length + " points."
}

属性文档

distance : real

一个只读属性,用于存储该路线段所覆盖的距离(单位:米)。

maneuver : RouteManeuver

只读属性,用于存储该路线段的机动动作。

如果该路线段的终点未附加任何信息,则将返回无效的转向操作。

path : list<coordinate>

只读属性,用于存储该路段的地理坐标。坐标按沿该路段行进时所经过的顺序排列。

要访问单个路段,可以使用标准的列表访问器:'path.length' 表示对象的数量,而 'path[从零开始的索引]' 则返回相应的对象。

另请参阅 QtPositioning::coordinate 。

travelTime : int

一个只读属性,用于存储遍历该区段预计所需的时间(以秒为单位)。

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