QGeoLocation Class | Qt Positioning | Qt 6.10.3
Description: The QGeoLocation class represents basic information about a location.

- Qt 6.10
- Qt Positioning
- C++ Classes
- QGeoLocation
- Qt 6.10.3 Reference Documentation

# QGeoLocation Class

The QGeoLocation class represents basic information about a location. More...

Header: | `#include <QGeoLocation>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Positioning)` `target_link_libraries(mytarget PRIVATE Qt6::Positioning)`
qmake: | `QT += positioning`

- List of all members, including inherited members

## Public Functions

| QGeoLocation()
| QGeoLocation(const QGeoLocation &other)
`(since 6.2)` | QGeoLocation(QGeoLocation &&other)
| ~QGeoLocation()
QGeoAddress | address() const
`(since 6.2)` QGeoShape | boundingShape() const
QGeoCoordinate | coordinate() const
QVariantMap | extendedAttributes() const
bool | isEmpty() const
void | setAddress(const QGeoAddress &address)
`(since 6.2)` void | setBoundingShape(const QGeoShape &boundingShape)
void | setCoordinate(const QGeoCoordinate &coordinate)
void | setExtendedAttributes(const QVariantMap &data)
`(since 6.2)` void | swap(QGeoLocation &other)
`(since 6.2)` QGeoLocation & | operator=(QGeoLocation &&other)
QGeoLocation & | operator=(const QGeoLocation &other)

## Related Non-Members

size_t | qHash(const QGeoLocation &location, size_t seed = 0)
bool | operator!=(const QGeoLocation &lhs, const QGeoLocation &rhs)
bool | operator==(const QGeoLocation &lhs, const QGeoLocation &rhs)

## Detailed Description

A QGeoLocation consists of a coordinate and corresponding address, along with an optional bounding shape, which is the recommended region to be displayed when viewing the location.

## Member Function Documentation

### QGeoLocation::QGeoLocation()

Constructs an new location object.

### QGeoLocation::QGeoLocation(const QGeoLocation &other)

Constructs a copy of other

### `[noexcept, since 6.2]` QGeoLocation::QGeoLocation(QGeoLocation &&other)

Constructs a geo location object by moving from other.

Note: The moved-from QGeoLocation object can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

This function was introduced in Qt 6.2.

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

Destroys the location object.

### QGeoAddress QGeoLocation::address() const

Returns the address of the location.

See also setAddress().

### `[since 6.2]` QGeoShape QGeoLocation::boundingShape() const

Returns a bounding shape which represents the recommended region to display when viewing this location.

For example, a building's location may have a region centered around the building, but the region is large enough to show it's immediate surrounding geographical context.

Note: This method was introduced in Qt6 instead of boundingBox() method. It returns a QGeoShape instead of a QGeoRectangle. Use QGeoShape::boundingGeoRectangle() to obtain a bounding QGeoRectangle for the shape.

This function was introduced in Qt 6.2.

See also setBoundingShape().

### QGeoCoordinate QGeoLocation::coordinate() const

Returns the coordinate of the location.

See also setCoordinate().

### QVariantMap QGeoLocation::extendedAttributes() const

Returns the extended attributes associated to this location. Extended attributes are backend-dependent and can be location-dependent.

See also setExtendedAttributes().

### bool QGeoLocation::isEmpty() const

Returns `true` if the location coordinate is invalid, and all the other location fields are empty. Otherwise returns `false`.

### void QGeoLocation::setAddress(const QGeoAddress &address)

Sets the address of the location.

See also address().

### `[since 6.2]` void QGeoLocation::setBoundingShape(const QGeoShape &boundingShape)

Sets the boundingShape of the location.

This function was introduced in Qt 6.2.

See also boundingShape().

### void QGeoLocation::setCoordinate(const QGeoCoordinate &coordinate)

Sets the coordinate of the location.

See also coordinate().

### void QGeoLocation::setExtendedAttributes(const QVariantMap &data)

Sets the extended attributes of the location with the parameters specified in data.

See also extendedAttributes().

### `[noexcept, since 6.2]` void QGeoLocation::swap(QGeoLocation &other)

Swaps this location with other. This operation is very fast and never fails.

This function was introduced in Qt 6.2.

### `[noexcept, since 6.2]` QGeoLocation &QGeoLocation::operator=(QGeoLocation &&other)

Move-assings other to this location and returns a reference to this location.

Note: The moved-from QGeoLocation object can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

This function was introduced in Qt 6.2.

### QGeoLocation &QGeoLocation::operator=(const QGeoLocation &other)

Assigns other to this location and returns a reference to this location.

## Related Non-Members

### `[noexcept]` size_t qHash(const QGeoLocation &location, size_t seed = 0)

Returns the hash value for the location, using seed for the calculation.

Note: The hash does not take extended attributes into account. This means that two geo location objects that differ only in the extended attributes will provide similar hashes.

### bool operator!=(const QGeoLocation &lhs, const QGeoLocation &rhs)

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

### bool operator==(const QGeoLocation &lhs, const QGeoLocation &rhs)

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