本页内容

QGeoRouteSegment Class

QGeoRouteSegment 类表示路线中的一个路段。更多...

Header: #include <QGeoRouteSegment>
qmake: QT += location

属性

公开活动

QGeoRouteSegment()
QGeoRouteSegment(const QGeoRouteSegment &other)
QGeoRouteSegment(QGeoRouteSegment &&other)
~QGeoRouteSegment()
qreal distance() const
bool isLegLastSegment() const
bool isValid() const
QGeoManeuver maneuver() const
QGeoRouteSegment nextRouteSegment() const
QList<QGeoCoordinate> path() const
void setNextRouteSegment(const QGeoRouteSegment &routeSegment)
int travelTime() const
QGeoRouteSegment &operator=(const QGeoRouteSegment &other)
bool operator!=(const QGeoRouteSegment &lhs, const QGeoRouteSegment &rhs)
bool operator==(const QGeoRouteSegment &lhs, const QGeoRouteSegment &rhs)

详细说明

一个 QGeoRouteSegment 实例包含有关路线段物理布局、路线长度以及穿越该路线段所需预估时间的信息,并可选地关联一个与路线段起点相关的QGeoManeuver 。

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

属性文档

[read-only] distance : const qreal

该属性存储该路线段所经过的距离,单位为米。

访问函数:

qreal distance() const

[read-only] maneuver : const QGeoManeuver

该属性存储了该路线段的机动动作。

如果该路线段的起点未关联任何信息,则存储一个无效的QGeoManeuver 。

访问函数:

QGeoManeuver maneuver() const

[read-only] path : const QList<QGeoCoordinate>

该属性存储了该路线路段的几何形状。

坐标应按沿该路线段行进时实际经过的顺序排列。

访问函数:

QList<QGeoCoordinate> path() const

[read-only] travelTime : const int

该属性存储了穿越该路段所需时间的估计值(单位为秒)。

访问函数:

int travelTime() const

成员函数文档

QGeoRouteSegment::QGeoRouteSegment()

构建一个无效的路线段对象。

在调用setNextRouteSegment()、setTravelTime()、setDistance()、setPath()或setManeuver()中的任意一个方法之前,该路线段将保持无效状态。

[noexcept] QGeoRouteSegment::QGeoRouteSegment(const QGeoRouteSegment &other)

根据other 中的内容构建一个路线段对象。

[constexpr noexcept default] QGeoRouteSegment::QGeoRouteSegment(QGeoRouteSegment &&other)

通过Move构造一个QGeoRouteSegment 的实例。

[noexcept] QGeoRouteSegment::~QGeoRouteSegment()

删除此路线段对象。

bool QGeoRouteSegment::isLegLastSegment() const

返回此路线段是否为路线区段的最后一个段。

bool QGeoRouteSegment::isValid() const

返回该路由段是否有效。

如果在路由的最后一个路由段上调用nextRouteSegment(),则返回值将是一个无效的路由段。

QGeoRouteSegment QGeoRouteSegment::nextRouteSegment() const

返回路由中的下一个路由段。

如果这是该路由中的最后一个路由段,则将返回一个无效的路由段。

另请参阅 ` setNextRouteSegment()`。

void QGeoRouteSegment::setNextRouteSegment(const QGeoRouteSegment &routeSegment)

将路线中的下一路段设置为routeSegment 。

另请参阅 nextRouteSegment()。

[noexcept] QGeoRouteSegment &QGeoRouteSegment::operator=(const QGeoRouteSegment &other)

将other 分配给此路线段对象,然后返回对此路线段对象的引用。

相关的非成员

[noexcept] bool operator!=(const QGeoRouteSegment &lhs, const QGeoRouteSegment &rhs)

返回路由段lhs 和rhs 是否不相同。

比较时不考虑nextRouteSegment() 的值。

[noexcept] bool operator==(const QGeoRouteSegment &lhs, const QGeoRouteSegment &rhs)

返回路由段lhs 和rhs 是否相等。

比较时不考虑nextRouteSegment() 的值。

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