- Qt 6.10
- Qt Positioning
- C++ Classes
- QGeoAddress
- Qt 6.10.2 Reference Documentation

# QGeoAddress Class

The QGeoAddress class represents an address of a QGeoLocation. More...

Header: | `#include <QGeoAddress>`
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

| QGeoAddress()
| QGeoAddress(const QGeoAddress &other)
`(since 6.2)` | QGeoAddress(QGeoAddress &&other)
| ~QGeoAddress()
QString | city() const
void | clear()
QString | country() const
QString | countryCode() const
QString | county() const
QString | district() const
bool | isEmpty() const
bool | isTextGenerated() const
QString | postalCode() const
void | setCity(const QString &city)
void | setCountry(const QString &country)
void | setCountryCode(const QString &countryCode)
void | setCounty(const QString &county)
void | setDistrict(const QString &district)
void | setPostalCode(const QString &postalCode)
void | setState(const QString &state)
void | setStreet(const QString &street)
`(since 6.2)` void | setStreetNumber(const QString &streetNumber)
void | setText(const QString &text)
QString | state() const
QString | street() const
`(since 6.2)` QString | streetNumber() const
`(since 6.2)` void | swap(QGeoAddress &other)
QString | text() const
`(since 6.2)` QGeoAddress & | operator=(QGeoAddress &other)
QGeoAddress & | operator=(const QGeoAddress &address)

## Related Non-Members

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

## Detailed Description

The address' attributes are normalized to US feature names and can be mapped to the local feature levels (for example State matches "Bundesland" in Germany).

The address contains a text() for displaying purposes and additional properties to access the components of an address:

- QGeoAddress::country()
- QGeoAddress::countryCode()
- QGeoAddress::state()
- QGeoAddress::city()
- QGeoAddress::district()
- QGeoAddress::street()
- QGeoAddress::postalCode()

## Member Function Documentation

### QGeoAddress::QGeoAddress()

Default constructor.

### QGeoAddress::QGeoAddress(const QGeoAddress &other)

Constructs a copy of other.

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

Constructs a geo address object by moving from other.

Note: The moved-from QGeoAddress 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]` QGeoAddress::~QGeoAddress()

Destroys this address.

### QString QGeoAddress::city() const

Returns the city.

See also setCity().

### void QGeoAddress::clear()

Clears all of the address' data fields.

### QString QGeoAddress::country() const

Returns the country name.

See also setCountry().

### QString QGeoAddress::countryCode() const

Returns the country code according to ISO 3166-1 alpha-3

See also setCountryCode().

### QString QGeoAddress::county() const

Returns the county. The county is considered the second subdivision below country.

See also setCounty().

### QString QGeoAddress::district() const

Returns the district. The district is considered the subdivison below city.

See also setDistrict().

### bool QGeoAddress::isEmpty() const

Returns whether this address is empty. An address is considered empty if all of its fields are empty.

### bool QGeoAddress::isTextGenerated() const

Returns true if QGeoAddress::text() is automatically generated from address elements, otherwise returns false if text() has been explicitly assigned.

See also text() and setText().

### QString QGeoAddress::postalCode() const

Returns the postal code.

See also setPostalCode().

### void QGeoAddress::setCity(const QString &city)

Sets the city.

See also city().

### void QGeoAddress::setCountry(const QString &country)

Sets the country name.

See also country().

### void QGeoAddress::setCountryCode(const QString &countryCode)

Sets the countryCode according to ISO 3166-1 alpha-3

See also countryCode().

### void QGeoAddress::setCounty(const QString &county)

Sets the county.

See also county().

### void QGeoAddress::setDistrict(const QString &district)

Sets the district.

See also district().

### void QGeoAddress::setPostalCode(const QString &postalCode)

Sets the postalCode.

See also postalCode().

### void QGeoAddress::setState(const QString &state)

Sets the state.

See also state().

### void QGeoAddress::setStreet(const QString &street)

Sets the street name to street.

Note: Before Qt6 this could also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another. Use setStreetNumber() to set this data now.

See also street() and setStreetNumber().

### `[since 6.2]` void QGeoAddress::setStreetNumber(const QString &streetNumber)

Sets the street number to streetNumber.

This may also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another.

Note: Before Qt6 this information was set by setStreet() method.

This function was introduced in Qt 6.2.

See also streetNumber() and setStreet().

### void QGeoAddress::setText(const QString &text)

If text is not empty, explicitly assigns text as the string to be returned by text(). isTextGenerated() will return false.

If text is empty, indicates that text() should be automatically generated from the address elements. isTextGenerated() will return true.

See also text().

### QString QGeoAddress::state() const

Returns the state. The state is considered the first subdivision below country.

See also setState().

### QString QGeoAddress::street() const

Returns the street name.

Note: Before Qt6 this could also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another. Use streetNumber() to obtain this data now.

See also setStreet() and streetNumber().

### `[since 6.2]` QString QGeoAddress::streetNumber() const

Returns the street number.

This may also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another.

Note: Before Qt6 this information was returned by street() method.

This function was introduced in Qt 6.2.

See also setStreetNumber() and street().

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

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

This function was introduced in Qt 6.2.

### QString QGeoAddress::text() const

Returns the address as a single formatted string. It is the recommended string to use to display the address to the user. It typically takes the format of an address as found on an envelope, but this is not always necessarily the case.

The address text is either automatically generated or explicitly assigned. This can be determined by checking isTextGenerated.

If an empty string is provided to setText(), then isTextGenerated() will be set to `true` and text() will return a string which is locally formatted according to countryCode() and based on the elements of the address such as street, city and so on. Because the text string is generated from the address elements, a sequence of calls such as text(), setStreet(), text() may return different strings for each invocation of text().

If a non-empty string is provided to setText(), then isTextGenerated() will be set to `false` and text() will always return the explicitly assigned string. Calls to modify other elements such as setStreet(), setCity() and so on will not affect the resultant string from text().

See also setText().

### `[default, since 6.2]` QGeoAddress &QGeoAddress::operator=(QGeoAddress &other)

Move-assigns the other to this address and returns a reference to this address.

Note: The moved-from QGeoAddress 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.

### QGeoAddress &QGeoAddress::operator=(const QGeoAddress &address)

Assigns the given address to this address and returns a reference to this address.

## Related Non-Members

### `[noexcept]` size_t qHash(const QGeoAddress &address, size_t seed = 0)

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

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

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

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

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