QPlaceSearchResult Class

QPlaceSearchResult 类是搜索结果的基类。更多

Header: #include <QPlaceSearchResult>
qmake: QT += location
Inherited By:

QPlaceProposedSearchResult and QPlaceResult

公共类型

enum SearchResultType { UnknownSearchResult, PlaceResult, ProposedSearchResult }

公共函数

QPlaceSearchResult()
QPlaceSearchResult(const QPlaceSearchResult &other)
virtual ~QPlaceSearchResult()
QPlaceIcon icon() const
void setIcon(const QPlaceIcon &icon)
void setTitle(const QString &title)
QString title() const
QPlaceSearchResult::SearchResultType type() const
bool operator!=(const QPlaceSearchResult &other) const
QPlaceSearchResult &operator=(const QPlaceSearchResult &other)
bool operator==(const QPlaceSearchResult &other) const

详细说明

在成功完成请求后,可从QPlaceSearchReply 获取搜索结果列表。所有搜索结果的共同点是titleicon ,可用于向用户展示搜索结果。

根据type ,搜索结果可以转换为更详细的子类,如图所示:

if(result.type()==QPlaceSearchResult::PlaceResult) { QPlaceResultplaceResult=result.type()    qDebug() << placeResult.place().name();
    qDebug() << placeResult.place().location().coordinate();
    qDebug() << placeResult.distance();
}

这种实现方式不会产生对象分片的问题。我们不希望客户端应用程序或后台插件直接实例化 QPlaceSearchResult,客户端应用程序只需转换为搜索结果子类,后台插件只需实例化子类。

另请参阅 QPlaceResult

成员类型文档

enum QPlaceSearchResult::SearchResultType

定义搜索结果类型

常数说明
QPlaceSearchResult::UnknownSearchResult0搜索结果内容未知。
QPlaceSearchResult::PlaceResult1搜索结果包含一个地点。
QPlaceSearchResult::ProposedSearchResult2搜索结果包含可能相关的搜索建议。

成员函数文档

QPlaceSearchResult::QPlaceSearchResult()

创建新的搜索结果。

QPlaceSearchResult::QPlaceSearchResult(const QPlaceSearchResult &other)

构建一个other

[virtual noexcept] QPlaceSearchResult::~QPlaceSearchResult()

销毁搜索结果。

QPlaceIcon QPlaceSearchResult::icon() const

返回一个可用于表示搜索结果的图标。

另请参阅 setIcon()。

void QPlaceSearchResult::setIcon(const QPlaceIcon &icon)

将搜索结果的图标设置为icon

另请参阅 icon() 。

void QPlaceSearchResult::setTitle(const QString &title)

将搜索结果的标题设置为title

另请参阅 title() 。

QString QPlaceSearchResult::title() const

返回搜索结果的标题。该字符串可用于向用户显示搜索结果。

另请参阅 setTitle()。

QPlaceSearchResult::SearchResultType QPlaceSearchResult::type() const

返回结果类型。

bool QPlaceSearchResult::operator!=(const QPlaceSearchResult &other) const

如果other 不等于此搜索结果,则返回 true,否则返回 false。

QPlaceSearchResult &QPlaceSearchResult::operator=(const QPlaceSearchResult &other)

为该搜索结果指定other ,并返回对该搜索结果的引用。

bool QPlaceSearchResult::operator==(const QPlaceSearchResult &other) const

如果other 等于此搜索结果,则返回 true,否则返回 false。

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