QPlaceSearchResult Class

The QPlaceSearchResult class is the base class for search results. 更多...

头: #include <QPlaceSearchResult>
qmake: QT += location
Since: Qt 5.6
继承者: 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
SearchResultType type () const
bool operator!= (const QPlaceSearchResult & other ) const
QPlaceSearchResult & operator= (const QPlaceSearchResult & other )
bool operator== (const QPlaceSearchResult & other ) const

详细描述

The QPlaceSearchResult class is the base class for search results.

A list of search results can be retrieved from the QPlaceSearchReply after it has successfully completed the request. Common to all search results are the title and icon , which can be used to present the search result to the user.

The intended usage is that depending on the type , the search result can be converted to a more detailed subclass 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. It is not expected that client applications or backend plugins instantiate a QPlaceSearchResult directly, but rather client applications simply convert to search result subclasses and backend plugins only instantiate subclasses.

另请参阅 QPlaceResult .

成员类型文档编制

enum QPlaceSearchResult:: SearchResultType

Defines the type of search result

常量 描述
QPlaceSearchResult::UnknownSearchResult 0 The contents of the search result are unknown.
QPlaceSearchResult::PlaceResult 1 The search result contains a place.
QPlaceSearchResult::ProposedSearchResult 2 The search result contains a proposed search which may be relevant.

成员函数文档编制

QPlaceSearchResult:: QPlaceSearchResult ()

Constructs a new search result.

QPlaceSearchResult:: QPlaceSearchResult (const QPlaceSearchResult & other )

构造副本为 other

[虚拟] QPlaceSearchResult:: ~QPlaceSearchResult ()

Destroys the search result.

QPlaceIcon QPlaceSearchResult:: icon () const

Returns an icon that can be used to represent the search result.

另请参阅 setIcon ().

void QPlaceSearchResult:: setIcon (const QPlaceIcon & icon )

Sets the icon of the search result to icon .

另请参阅 icon ().

void QPlaceSearchResult:: setTitle (const QString & title )

Sets the title of the search result to title .

另请参阅 title ().

QString QPlaceSearchResult:: title () const

Returns the title of the search result. This string can be used to display the search result to the user.

另请参阅 setTitle ().

SearchResultType QPlaceSearchResult:: type () const

Returns the result type.

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

返回 true 若 other not equal to this search result, otherwise returns false.

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

赋值 other to this search result and returns a reference to this search result.

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

返回 true 若 other is equal to this search result, otherwise returns false.