QPlaceResult Class

The QPlaceResult class represents a search result containing a place. 更多...

头文件: #include <QPlaceResult>
qmake: QT += location
开始支持版本: Qt 5.6
基类: 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)

详细描述

The QPlaceResult class represents a search result containing a place.

The PlaceResult holds the distance to the place from the center of the search request, an instance of the place and an indication of whether the result is sponsored or organic.

The intended usage is that a QPlaceSearchResult can be converted into a QPlaceResult like so:


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

The implementation is handled in such a way that object slicing is not an issue.

参见 QPlaceSearchResult.

成员函数

QPlaceResult::QPlaceResult()

Constructs a new place result object.

QPlaceResult::QPlaceResult(const QPlaceSearchResult &other)

Constructs a copy of other if possible, otherwise constructs a default place result.

[virtual] QPlaceResult::~QPlaceResult()

Destructor.

qreal QPlaceResult::distance() const

Returns the distance of the place to the search center. This field is only relevant provided the search request contained a search area with a search center. Otherwise, the distance is NaN indicating an undefined distance. The default value for distance is NaN.

参见 setDistance().

bool QPlaceResult::isSponsored() const

Returns true if the result is a sponsored result.

参见 setSponsored().

QPlace QPlaceResult::place() const

Returns the place of the search result.

参见 setPlace().

void QPlaceResult::setDistance(qreal distance)

Set the distance of the search result's place from a search center.

参见 distance().

void QPlaceResult::setPlace(const QPlace &place)

Sets the place that this result refers to.

参见 place().

void QPlaceResult::setSponsored(bool sponsored)

Sets whether the result is a sponsored result or not.

参见 isSponsored().