- Qt 6.10
- Qt Location
- C++ Classes
- QPlaceSearchRequest
- Qt 6.10.2 Reference Documentation

# QPlaceSearchRequest Class

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

Header: | `#include <QPlaceSearchRequest>`
qmake: | `QT += location`

- List of all members, including inherited members

## Public Types

enum | RelevanceHint { UnspecifiedHint, DistanceHint, LexicalPlaceNameHint }

## Public Functions

| QPlaceSearchRequest()
| QPlaceSearchRequest(const QPlaceSearchRequest &other)
| ~QPlaceSearchRequest()
QList<QPlaceCategory> | categories() const
void | clear()
int | limit() const
QString | recommendationId() const
QPlaceSearchRequest::RelevanceHint | relevanceHint() const
QGeoShape | searchArea() const
QVariant | searchContext() const
QString | searchTerm() const
void | setCategories(const QList<QPlaceCategory> &categories)
void | setCategory(const QPlaceCategory &category)
void | setLimit(int limit)
void | setRecommendationId(const QString &placeId)
void | setRelevanceHint(QPlaceSearchRequest::RelevanceHint hint)
void | setSearchArea(const QGeoShape &area)
void | setSearchContext(const QVariant &context)
void | setSearchTerm(const QString &term)
void | setVisibilityScope(QLocation::VisibilityScope scope)
QLocation::VisibilityScope | visibilityScope() const
QPlaceSearchRequest & | operator=(const QPlaceSearchRequest &other)

## Related Non-Members

bool | operator!=(const QPlaceSearchRequest &lhs, const QPlaceSearchRequest &rhs)
bool | operator==(const QPlaceSearchRequest &lhs, const QPlaceSearchRequest &rhs)

## 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.

Constant | Value | Description
--- | --- | ---
`QPlaceSearchRequest::UnspecifiedHint` | `0` | No explicit hint has been specified.
`QPlaceSearchRequest::DistanceHint` | `1` | Distance 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::LexicalPlaceNameHint` | `2` | Alphabetic ordering of places according to name is relevant to the user.

## Member Function Documentation

### QPlaceSearchRequest::QPlaceSearchRequest()

Default constructor. Constructs an new request object.

### `[noexcept]` QPlaceSearchRequest::QPlaceSearchRequest(const QPlaceSearchRequest &other)

Constructs a copy of other.

### `[noexcept]` QPlaceSearchRequest::~QPlaceSearchRequest()

Destroys the request object.

### QList<QPlaceCategory> QPlaceSearchRequest::categories() const

Return the categories to be used in the search request. Places need only to belong to one of the categories to be considered a match by the request.

See also setCategories().

### void QPlaceSearchRequest::clear()

Clears the search request.

### int QPlaceSearchRequest::limit() const

Returns the maximum number of search results to retrieve.

A negative value for limit means that it is undefined. It is left up to the backend provider to choose an appropriate number of results to return. The default limit is -1.

See also setLimit().

### QString QPlaceSearchRequest::recommendationId() const

Returns the place id which will be used to search for recommendations for similar places.

See also setRecommendationId().

### QPlaceSearchRequest::RelevanceHint QPlaceSearchRequest::relevanceHint() const

Returns the relevance hint of the request. The hint is given to the provider to help but not dictate the ranking of results. For example providing a distance hint may give closer places a higher ranking but it doesn't necessarily mean that he results will be ordered strictly according to distance.

See also setRelevanceHint().

### QGeoShape QPlaceSearchRequest::searchArea() const

Returns the search area which will be used to limit search results. The default search area is an invalid QGeoShape, indicating that no specific search area is defined.

See also setSearchArea().

### QVariant QPlaceSearchRequest::searchContext() const

Returns backend specific additional search context associated with this place search request. The search context is typically set as part of a proposed search results.

See also setSearchContext().

### QString QPlaceSearchRequest::searchTerm() const

Returns the search term.

See also setSearchTerm().

### void QPlaceSearchRequest::setCategories(const QList<QPlaceCategory> &categories)

Sets the search request to search from the list of given categories. Any places returned during the search will match at least one of the categories.

See also categories() and setCategory().

### void QPlaceSearchRequest::setCategory(const QPlaceCategory &category)

Sets the search request to search by a single category

See also setCategories().

### void QPlaceSearchRequest::setLimit(int limit)

Set the maximum number of search results to retrieve to limit.

See also limit().

### void QPlaceSearchRequest::setRecommendationId(const QString &placeId)

Sets the placeId which will be used to search for recommendations.

See also recommendationId().

### void QPlaceSearchRequest::setRelevanceHint(QPlaceSearchRequest::RelevanceHint hint)

Sets the relevance hint to be used when searching for a place.

See also relevanceHint().

### void QPlaceSearchRequest::setSearchArea(const QGeoShape &area)

Sets the search request to search within the given area.

See also searchArea().

### void QPlaceSearchRequest::setSearchContext(const QVariant &context)

Sets the search context to context.

Note: This method is intended to be used by geo service plugins when returning search results of type QPlaceSearchResult::ProposedSearchResult.

The search context is used by backends to store additional search context related to the search request. Other relevant fields should also be filled in. For example, if the search context encodes a text search the search term should also be set with setSearchTerm(). The search context allows additional search context to be kept which is not directly accessible via the Qt Location API.

The search context can be of any type storable in a QVariant. The value of the search context is not intended to be use directly by applications.

See also searchContext().

### void QPlaceSearchRequest::setSearchTerm(const QString &term)

Sets the search term.

See also searchTerm().

### void QPlaceSearchRequest::setVisibilityScope(QLocation::VisibilityScope scope)

Sets the visibility scope used when searching for places.

See also visibilityScope().

### QLocation::VisibilityScope QPlaceSearchRequest::visibilityScope() const

Returns the visibility scope used when searching for places. The default value is QLocation::UnspecifiedVisibility meaning that no explicit scope has been assigned. Places of any scope may be returned during the search.

See also setVisibilityScope().

### `[noexcept]` QPlaceSearchRequest &QPlaceSearchRequest::operator=(const QPlaceSearchRequest &other)

Assigns other to this search request and returns a reference to this search request.

## Related Non-Members

### `[noexcept]` bool operator!=(const QPlaceSearchRequest &lhs, const QPlaceSearchRequest &rhs)

Returns true if lhs is not equal to rhs, otherwise returns false.

### `[noexcept]` bool operator==(const QPlaceSearchRequest &lhs, const QPlaceSearchRequest &rhs)

Returns true if lhs is equal to rhs, otherwise returns false.