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() 。
© 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.