QGeoRouteReply Class
QGeoRouteReply 类用于管理由QGeoRoutingManager 实例启动的操作。更多内容...
| Header: | #include <QGeoRouteReply> |
| qmake: | QT += location |
| Inherits: | QObject |
公共类型
| enum | Error { NoError, EngineNotSetError, CommunicationError, ParseError, UnsupportedOptionError, UnknownError } |
公共函数
| QGeoRouteReply(QGeoRouteReply::Error error, const QString &errorString, QObject *parent = nullptr) | |
| virtual | ~QGeoRouteReply() |
| virtual void | abort() |
| QGeoRouteReply::Error | error() const |
| QString | errorString() const |
| bool | isFinished() const |
| QGeoRouteRequest | request() const |
| QList<QGeoRoute> | routes() const |
信号
| void | aborted() |
| void | errorOccurred(QGeoRouteReply::Error error, const QString &errorString = QString()) |
| void | finished() |
受保护函数
| QGeoRouteReply(const QGeoRouteRequest &request, QObject *parent = nullptr) | |
| void | addRoutes(const QList<QGeoRoute> &routes) |
| void | setError(QGeoRouteReply::Error error, const QString &errorString) |
| void | setFinished(bool finished) |
| void | setRoutes(const QList<QGeoRoute> &routes) |
详细描述
QGeoRouteReply 的实例用于管理这些操作的状态和结果。
isFinished()、error() 和errorString() 方法提供有关操作是否已完成以及是否成功完成的信息。
finished()、errorOccurred(QGeoRouteReply::Error,QString) 信号可用于监控操作的进度。
新创建的 QGeoRouteReply 实例可能处于已完成状态,最常见的原因是发生了错误。由于此类实例永远不会发出finished() 或errorOccurred(QGeoRouteReply::Error,QString) 信号,因此在连接这些信号之前,务必检查isFinished() 的结果。QGeoRoutingManager 的文档演示了如何实现这一点。
如果操作成功完成,则可通过routes() 访问结果。
成员类型文档
enum QGeoRouteReply::Error
描述了导致操作无法完成的错误。
| 常量 | 值 | 描述 |
|---|---|---|
QGeoRouteReply::NoError | 0 | 未发生错误。 |
QGeoRouteReply::EngineNotSetError | 1 | 所使用的路由管理器未关联任何QGeoRoutingManagerEngine 实例。 |
QGeoRouteReply::CommunicationError | 2 | 与服务提供商通信时发生错误。 |
QGeoRouteReply::ParseError | 3 | 服务提供商的响应格式无法识别。 |
QGeoRouteReply::UnsupportedOptionError | 4 | 服务提供商不支持所请求的操作或该操作的某个选项。 |
QGeoRouteReply::UnknownError | 5 | 发生了一个不属于其他任何类别的错误。 |
成员函数文档
[explicit protected] QGeoRouteReply::QGeoRouteReply(const QGeoRouteRequest &request, QObject *parent = nullptr)
根据request ,并使用指定的parent ,构建一个路由响应对象。
[explicit] QGeoRouteReply::QGeoRouteReply(QGeoRouteReply::Error error, const QString &errorString, QObject *parent = nullptr)
根据给定的error 和errorString 以及指定的parent ,构建一个路由响应。
[virtual noexcept] QGeoRouteReply::~QGeoRouteReply()
销毁此路由响应对象。
[virtual] void QGeoRouteReply::abort()
立即取消该操作。
如果响应已完成,此操作将不产生任何效果。
[signal] void QGeoRouteReply::aborted()
当操作被取消时,会发出此信号。
另请参阅 abort()。
[protected] void QGeoRouteReply::addRoutes(const QList<QGeoRoute> &routes)
将routes 列表追加到现有列表中。
QGeoRouteReply::Error QGeoRouteReply::error() const
返回此响应的错误状态。
如果结果为QGeoRouteReply::NoError ,则表示未发生错误。
另请参阅 setError()。
[signal] void QGeoRouteReply::errorOccurred(QGeoRouteReply::Error error, const QString &errorString = QString())
当在处理此响应时检测到错误时,将发出此信号。随后可能会发出finished()信号。
该错误将由错误代码error 描述。如果errorString 不为空,则其中将包含该错误的文本描述。
该信号与QGeoRoutingManager::errorOccurred()将同时触发。
注意:请 勿在连接到此信号的槽中删除此响应对象。请改用deleteLater() 函数。
QString QGeoRouteReply::errorString() const
返回此响应的错误状态的文本表示形式。
如果未发生错误,则返回空字符串。也可能发生了没有关联文本表示形式的错误,这种情况下也会返回空字符串。
要确定是否发生了错误,请检查QGeoRouteReply::error()是否等于QGeoRouteReply::NoError 。
[signal] void QGeoRouteReply::finished()
当此响应处理完成时,将发出此信号。
如果error()的值等于QGeoRouteReply::NoError ,则表示处理已成功完成。
该信号与QGeoRoutingManager::finished()将同时发出。
注意:请 勿在连接到此信号的槽中删除此回复对象。请改用deleteLater()。
另请参阅 setFinished()。
bool QGeoRouteReply::isFinished() const
如果操作成功完成,或遇到导致操作中止的错误,则返回 true。
QGeoRouteRequest QGeoRouteReply::request() const
返回指定该路由的路由请求。
QList<QGeoRoute> QGeoRouteReply::routes() const
返回所请求的路由列表。
另请参阅 setRoutes()。
[protected] void QGeoRouteReply::setError(QGeoRouteReply::Error error, const QString &errorString)
将此响应的错误状态设置为error ,并将错误的文本表示设置为errorString 。
这还将按此顺序触发errorOccurred() 和finished() 信号。
另请参阅 error()。
[protected] void QGeoRouteReply::setFinished(bool finished)
用于设置此响应是否已完成,该信息将发送至finished 。
如果finished 为 true,这将触发finished() 信号。
如果操作成功完成,应在调用本函数之前先调用QGeoRouteReply::setRoutes()。如果发生错误,则应改用QGeoRouteReply::setError()。
另请参阅 finished()。
[protected] void QGeoRouteReply::setRoutes(const QList<QGeoRoute> &routes)
设置对routes 的响应中的路由列表。
另请参阅 routes()。
© 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.