QGeoCodeReply Class

QGeoCodeReply 类管理由QGeoCodingManager 实例启动的操作 ... 更多...

Header: #include <QGeoCodeReply>
qmake: QT += location
Inherits: QObject

公共类型

enum Error { NoError, EngineNotSetError, CommunicationError, ParseError, UnsupportedOptionError, …, UnknownError }

公共函数

QGeoCodeReply(QGeoCodeReply::Error error, const QString &errorString, QObject *parent = nullptr)
virtual ~QGeoCodeReply()
virtual void abort()
QGeoCodeReply::Error error() const
QString errorString() const
bool isFinished() const
qsizetype limit() const
QList<QGeoLocation> locations() const
qsizetype offset() const
QGeoShape viewport() const

信号

void aborted()
void errorOccurred(QGeoCodeReply::Error error, const QString &errorString = QString())
void finished()

受保护函数

QGeoCodeReply(QObject *parent = nullptr)
void addLocation(const QGeoLocation &location)
void setError(QGeoCodeReply::Error error, const QString &errorString)
void setFinished(bool finished)
void setLimit(qsizetype limit)
void setLocations(const QList<QGeoLocation> &locations)
void setOffset(qsizetype offset)
void setViewport(const QGeoShape &viewport)

详细说明

QGeoCodeReply 实例管理这些操作的状态和结果。

isFinished(),error() 和errorString() 方法提供操作是否完成以及是否成功完成的信息。

finished() 和errorOccurred(QGeoCodeReply::Error,QString) 信号可用于监控操作的进度。

新创建的 QGeoCodeReply 有可能处于完成状态,最常见的原因是发生了错误。由于这样的实例永远不会发出finished() 或errorOccurred(QGeoCodeReply::Error,QString) 信号,因此在与这些信号建立连接之前,必须检查isFinished() 的结果。QGeoCodingManager 的文档演示了如何执行该操作。

如果操作成功完成,就可以使用locations() 访问结果。

成员类型文档

enum QGeoCodeReply::Error

描述阻碍操作完成的错误。

常量说明
QGeoCodeReply::NoError0未发生错误。
QGeoCodeReply::EngineNotSetError1使用的地理编码管理器没有与之关联的QGeoCodingManagerEngine 实例。
QGeoCodeReply::CommunicationError2与服务提供商通信时发生错误。
QGeoCodeReply::ParseError3服务提供商的响应格式无法识别。
QGeoCodeReply::UnsupportedOptionError4服务提供商不支持请求的操作或操作的某个选项。
QGeoCodeReply::CombinationError5合并多个来源的结果时发生错误。
QGeoCodeReply::UnknownError6发生的错误不属于任何其他类别。

成员函数文档

[explicit protected] QGeoCodeReply::QGeoCodeReply(QObject *parent = nullptr)

用指定的parent 构建地理编码回复。

[explicit] QGeoCodeReply::QGeoCodeReply(QGeoCodeReply::Error error, const QString &errorString, QObject *parent = nullptr)

用给定的errorerrorString 以及指定的parent 构建地理编码回复。

[virtual noexcept] QGeoCodeReply::~QGeoCodeReply()

销毁此回复对象。

[virtual] void QGeoCodeReply::abort()

立即取消操作。

如果回复已完成,则不会执行任何操作。

另请参阅 aborted().

[signal] void QGeoCodeReply::aborted()

该信号在操作取消时发出。

另请参阅 abort().

[protected] void QGeoCodeReply::addLocation(const QGeoLocation &location)

location 添加到本回复的地点列表中。

QGeoCodeReply::Error QGeoCodeReply::error() const

返回此回复的错误状态。

如果结果是QGeoCodeReply::NoError ,则表示没有错误发生。

另请参阅 setError()。

[signal] void QGeoCodeReply::errorOccurred(QGeoCodeReply::Error error, const QString &errorString = QString())

当在处理该回复时检测到错误,就会发出该信号。随后可能会发出finished() 信号。

错误代码error 将描述该错误。如果errorString 不为空,则将包含错误的文字说明。

该信号和QGeoCodingManager::errorOccurred() 将同时发出。

注意: 请勿在与此信号相连的槽中删除此回复对象。请使用deleteLater() 代替。

QString QGeoCodeReply::errorString() const

返回此回复错误状态的文本表示。

如果没有错误发生,则返回空字符串。可能发生的错误没有相关的文本表示,在这种情况下也将返回空字符串。

要确定是否发生了错误,请检查QGeoCodeReply::error() 是否等于QGeoCodeReply::NoError

[signal] void QGeoCodeReply::finished()

该回复处理完毕后会发出该信号。

如果error() 等于QGeoCodeReply::NoError ,则表示处理已成功完成。

此信号和QGeoCodingManager::finished() 将同时发出。

注意: 请勿在与此信号相连的槽中删除此回复对象。请使用deleteLater() 代替。

另请参见 setFinished()。

bool QGeoCodeReply::isFinished() const

如果操作成功完成或遇到错误导致操作停止,则返回 true。

qsizetype QGeoCodeReply::limit() const

返回每个数据源的响应次数限制。

如果没有设置限制,该函数将返回-1。

如果响应数少于请求数,则返回值可能多于locations().length() 。

另请参阅 setLimit()。

QList<QGeoLocation> QGeoCodeReply::locations() const

返回位置列表。

这些位置是与创建此回复的QGeoCodingManager 函数相对应的操作结果。

另请参阅 setLocations()。

qsizetype QGeoCodeReply::offset() const

返回开始获取结果的整个结果集的偏移量。

另请参阅 setOffset()。

[protected] void QGeoCodeReply::setError(QGeoCodeReply::Error error, const QString &errorString)

将此回复的错误状态设置为error ,将错误的文本表示设置为errorString

这也将导致errorOccurred() 和finished() 信号依次发出。

另请参阅 error()。

[protected] void QGeoCodeReply::setFinished(bool finished)

设置finished 是否已完成回复。

如果finished 为 true,则会发出finished() 信号。

如果操作成功完成,应在调用此函数之前调用QGeoCodeReply::setLocations() 。如果发生错误,则应使用QGeoCodeReply::setError() 代替。

另请参见 finished()。

[protected] void QGeoCodeReply::setLimit(qsizetype limit)

将每个数据源的响应数量限制设置为limit

如果limit 为-1,则将返回所有可用的响应。

另请参阅 limit()。

[protected] void QGeoCodeReply::setLocations(const QList<QGeoLocation> &locations)

设置回复中的locations 列表。

另请参阅 locations().

[protected] void QGeoCodeReply::setOffset(qsizetype offset)

设置在整个结果集中开始获取结果的偏移量offset

另请参阅 offset() 。

[protected] void QGeoCodeReply::setViewport(const QGeoShape &viewport)

将包含结果的视口设置为viewport

另请参阅 viewport() 。

QGeoShape QGeoCodeReply::viewport() const

返回包含结果的视口。

如果在创建此回复的QGeoCodingManager 函数中没有指定视口偏置,则此函数将返回nullptr

另请参阅 setViewport() 。

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