QPlaceSearchResult 类
QPlaceSearchResult 类是搜索结果的基础类。 更多...
| 头文件 | #include <QPlaceSearchResult> | 
| qmake | QT += location | 
| 继承自 | 
公共类型
| 枚举 | SearchResultType { UnknownSearchResult, PlaceResult, ProposedSearchResult } | 
公共函数
| QPlaceSearchResult() | |
| QPlaceSearchResult(const QPlaceSearchResult &other) | |
| 虚函数 | ~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 获取搜索结果列表。所有搜索结果都共有 标题 和 图标,可以用作向用户呈现搜索结果。
预期的使用方式是根据 类型,搜索结果可以转换为一个更详细的子类,如下所示
if (result.type() == QPlaceSearchResult::PlaceResult) { QPlaceResult placeResult = result; qDebug() << placeResult.place().name(); qDebug() << placeResult.place().location().coordinate(); qDebug() << placeResult.distance(); }
实现以这种方式处理,以防止对象切片问题。不期望客户端应用程序或后端插件直接实例化 QPlaceSearchResult,而是客户端应用程序简单地转换为搜索结果子类,后端插件仅实例化子类。
参见QPlaceResult。
成员类型文档
enum QPlaceSearchResult::SearchResultType
定义搜索结果的类型
| 常量 | 值 | 描述 | 
|---|---|---|
| QPlaceSearchResult::UnknownSearchResult | 0 | 搜索结果的内容未知。 | 
| QPlaceSearchResult::PlaceResult | 1 | 搜索结果包含一个地点。 | 
| QPlaceSearchResult::ProposedSearchResult | 2 | 搜索结果包含可能相关的建议搜索。 | 
成员函数文档
QPlaceSearchResult::QPlaceSearchResult()
构建一个新的搜索结果。
QPlaceSearchResult::QPlaceSearchResult(const QPlaceSearchResult &other)
构建other的副本。
[虚函数 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。
© 2024 The Qt Company Ltd。此文件中包含的文档贡献是该文件所有者的版权。