QPlaceResult Class
QPlaceResult 类表示一个包含地点的搜索结果。更多内容...
| Header: | #include <QPlaceResult> |
| qmake: | QT += location |
| Inherits: | QPlaceSearchResult |
公共函数
| QPlaceResult() | |
| QPlaceResult(const QPlaceSearchResult &other) | |
| virtual | ~QPlaceResult() |
| qreal | distance() const |
| bool | isSponsored() const |
| QPlace | place() const |
| void | setDistance(qreal distance) |
| void | setPlace(const QPlace &place) |
| void | setSponsored(bool sponsored) |
详细说明
PlaceResult 对象包含从搜索请求中心点到该地点的距离、该地点的实例,以及该结果是赞助结果还是自然搜索结果的标识。
其预期用法是将QPlaceSearchResult 转换为QPlaceResult,具体如下:
if(result.type()==QPlaceSearchResult::PlaceResult) {
QPlaceResult placeResult=result;
qDebug() << placeResult.place().name();
qDebug() << placeResult.place().location().coordinate();
qDebug() << placeResult.distance();
}该实现方式确保了对象切片不会成为问题。
另请参阅 QPlaceSearchResult 。
成员函数文档
QPlaceResult::QPlaceResult()
创建一个新的位置结果对象。
QPlaceResult::QPlaceResult(const QPlaceSearchResult &other)
如果可能,则构建other 的副本;否则,构建一个默认的占位结果。
[virtual noexcept] QPlaceResult::~QPlaceResult()
析构函数。
qreal QPlaceResult::distance() const
返回该地点到搜索中心的距离。只有当搜索请求中包含具有搜索中心的搜索区域时,此字段才有效。否则,距离值为 NaN,表示距离未定义。distance 的默认值为 NaN。
另请参阅 setDistance()。
bool QPlaceResult::isSponsored() const
如果结果是赞助结果,则返回 true。
另请参阅 setSponsored()。
QPlace QPlaceResult::place() const
返回搜索结果的位置。
另请参阅 setPlace()。
void QPlaceResult::setDistance(qreal distance)
从搜索中心设置搜索结果位置的distance 。
另请参阅 distance()。
void QPlaceResult::setPlace(const QPlace &place)
设置此结果所引用的place 。
另请参阅 place()。
void QPlaceResult::setSponsored(bool sponsored)
用于设置结果是否为sponsored 结果。
另请参阅 isSponsored()。
© 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.