QPlaceSearchRequest Class

The QPlaceSearchRequest class represents the set of parameters for a search request. More...

Header: #include <QPlaceSearchRequest>
qmake: QT += location
Since: Qt 5.6

This class was introduced in Qt 5.6.

Public Types

enum RelevanceHint { UnspecifiedHint, DistanceHint, LexicalPlaceNameHint }

Detailed Description

A typical search request may look like the following:

 QPlaceSearchRequest searchRequest;
 searchRequest.setSearchTerm("Fast food"); //search term for what we are interested in

 //set a search center
 searchRequest.setSearchArea(QGeoCircle(QGeoCoordinate(2.3, 48.87)));

 //set a distance hint as a relevancy hint.
 //closer places have greater weighting in the ranking of results.
 searchRequest.setRelevanceHint(QPlaceSearchRequest::DistanceHint);

 //use limit to adjust pagination.
 //this limits the number of place results to 5 per page.
 searchRequest.setLimit(5);

 //provide some categories to narrow down search
 QList<QPlaceCategory> categories;
 categories << diner << restaurant;
 searchRequest.setCategories(categories);

Note that specifying a search center can be done by setting a circular search area that has a center but no radius. The default radius is set to -1, which indicates an undefined radius. The provider will interpret this as being free to choose its own default radius.

The QPlaceSearchRequest is primarily used with the QPlaceManager to search for places, however it is also used to provide parameters for generating search term suggestions. Note that in this context only some of the parameters may be relevant. For example, the search area is useful in narrowing down relevant search suggestions, while other parameters such as relevance hint are not so applicable.

Also be aware that providers may vary by which parameters they support for example some providers may not support paging while others do, some providers may honor relevance hints while others may completely ignore them, see the plugin documentation for more details.

Member Type Documentation

enum QPlaceSearchRequest::RelevanceHint

Defines hints to help rank place results.

ConstantValueDescription
QPlaceSearchRequest::UnspecifiedHint0No explicit hint has been specified.
QPlaceSearchRequest::DistanceHint1Distance to a search center is relevant for the user. Closer places are more highly weighted. This hint is only useful if a circular search area is used in the query.
QPlaceSearchRequest::LexicalPlaceNameHint2Alphabetic ordering of places according to name is relevant to the user.