QGeoRoute Class

QGeoRoute 类表示两点之间的路线。更多

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

属性

公共职能

QGeoRoute()
QGeoRoute(const QGeoRoute &other)
~QGeoRoute()
QGeoRectangle bounds() const
qreal distance() const
QVariantMap extendedAttributes() const
QGeoRouteSegment firstRouteSegment() const
int legIndex() const
QGeoRoute overallRoute() const
QList<QGeoCoordinate> path() const
QString routeId() const
QList<QGeoRoute> routeLegs() const
QList<QGeoRouteSegment> segments() const
qsizetype segmentsCount() const
void setFirstRouteSegment(const QGeoRouteSegment &routeSegment)
void setPath(const QList<QGeoCoordinate> &path)
void setTravelMode(QGeoRouteRequest::TravelMode mode)
QGeoRouteRequest::TravelMode travelMode() const
int travelTime() const
QGeoRoute &operator=(const QGeoRoute &other)

受保护的功能

QExplicitlySharedDataPointer<QGeoRoutePrivate> &d()
bool operator!=(const QGeoRoute &lhs, const QGeoRoute &rhs)
bool operator==(const QGeoRoute &lhs, const QGeoRoute &rhs)

详细说明

QGeoRoute 对象包含路线的高级信息,如路线长度、路线的预计旅行时间,以及在地图上渲染路线基本图像所需的足够信息。

QGeoRoute 对象还包含一个QGeoRouteSegment 对象列表,该列表更详细地描述了路线的各个分段。

路由信息通常使用QGeoRoutingManager::calculateRoute() 进行请求,它会返回一个QGeoRouteReply 实例。如果操作成功完成,则可通过QGeoRouteReply::routes() 访问路由信息。

另请参见 QGeoRoutingManager

属性文档

[read-only] bounds : const QGeoRectangle

该属性包含覆盖整个路线的边界框

访问功能

QGeoRectangle bounds() const

[read-only] distance : const qreal

该属性表示该路线的距离,单位为米

访问功能:

qreal distance() const

[read-only] extendedAttributes : const QVariantMap

此属性包含与此路由相关的扩展属性

访问功能:

QVariantMap extendedAttributes() const

[read-only] legIndex : const int

此属性保存此路线的路段索引

在包含QGeoRoute::routeLegs 的列表中,该路段的索引可用于查找下一个路段。

访问功能:

int legIndex() const

[read-only] overallRoute : const QGeoRoute

此属性表示包含此路线段的路线

如果此路线不是总路线中的一条支线,则此属性为空路线。

访问功能:

QGeoRoute overallRoute() const

path : QList<QGeoCoordinate>

该属性包含路线的几何形状

坐标应按照沿此路线段旅行的人穿越的顺序排列。

访问功能:

QList<QGeoCoordinate> path() const
void setPath(const QList<QGeoCoordinate> &path)

[read-only] routeId : const QString

此属性包含此路由的标识符

支持路由更新的服务提供商通常会为路由分配标识符。如果此路由来自此类服务提供商,那么更改标识符很可能会导致路由更新停止工作。

访问功能:

QString routeId() const

[read-only] routeLegs : const QList<QGeoRoute>

此属性保存多航点航线的航线legs

访问功能:

QList<QGeoRoute> routeLegs() const

[read-only] segments : const QList<QGeoRouteSegment>

此属性保存此路由的QGeoRouteSegment 对象列表

访问功能:

QList<QGeoRouteSegment> segments() const

[read-only] segmentsCount : const qsizetype

此属性表示路线中的路段数

访问功能:

qsizetype segmentsCount() const

[read-only] travelTime : const int

该属性包含穿越这条路线所需的估计时间,以秒为单位

访问函数:

int travelTime() const

成员函数文档

QGeoRoute::QGeoRoute()

构造路由对象。

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

根据other 的内容构建路由对象。

[noexcept] QGeoRoute::~QGeoRoute()

销毁此路由对象。

[protected] QExplicitlySharedDataPointer<QGeoRoutePrivate> &QGeoRoute::d()

返回私有实现。

QGeoRouteSegment QGeoRoute::firstRouteSegment() const

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

如果路由没有相关路由段,则返回无效路由段。

其余路由段可通过QGeoRouteSegment::nextRouteSegment 按顺序访问。

另请参阅 setFirstRouteSegment() 。

void QGeoRoute::setFirstRouteSegment(const QGeoRouteSegment &routeSegment)

将路由中的第一个路由段设置为routeSegment

另请参阅 firstRouteSegment()。

void QGeoRoute::setTravelMode(QGeoRouteRequest::TravelMode mode)

将此路径的行驶模式设置为mode

这应该是 request().travelModes() 返回的旅行模式之一。

另请参阅 travelMode()。

QGeoRouteRequest::TravelMode QGeoRoute::travelMode() const

返回此路径的行驶模式。

这应该是 request().travelModes() 返回的旅行模式之一。

另请参阅 setTravelMode()。

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

other 的内容赋值给此路由,并返回此路由的引用。

相关非会员

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

返回路由lhsrhs 是否不相等。

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

返回路由lhsrhs 是否相等。

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