QPlaceSearchResult Class
QPlaceSearchResult 类是搜索结果的基类。更多内容...
| Header: | #include <QPlaceSearchResult> |
| qmake: | QT += location |
| Inherited By: |
公共类型
| 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 成功完成请求后,可以从中获取搜索结果列表。所有搜索结果都包含title 和icon ,可用于向用户展示搜索结果。
其设计用途是:根据type 的不同,可以将搜索结果转换为更详细的子类,例如:
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
[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。
© 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.