Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGeoAddress Class Reference

\inmodule QtPositioning More...

#include <qgeoaddress.h>

+ Collaboration diagram for QGeoAddress:

Public Member Functions

 QGeoAddress ()
 Default constructor.
 
 QGeoAddress (const QGeoAddress &other)
 Constructs a copy of other.
 
 QGeoAddress (QGeoAddress &&other) noexcept=default
 
 ~QGeoAddress ()
 Destroys this address.
 
QGeoAddressoperator= (const QGeoAddress &other)
 Assigns the given address to this address and returns a reference to this address.
 
void swap (QGeoAddress &other) noexcept
 
QString text () const
 Returns the address as a single formatted string.
 
void setText (const QString &text)
 If text is not empty, explicitly assigns text as the string to be returned by text().
 
QString country () const
 Returns the country name.
 
void setCountry (const QString &country)
 Sets the country name.
 
QString countryCode () const
 Returns the country code according to ISO 3166-1 alpha-3.
 
void setCountryCode (const QString &countryCode)
 Sets the countryCode according to ISO 3166-1 alpha-3.
 
QString state () const
 Returns the state.
 
void setState (const QString &state)
 Sets the state.
 
QString county () const
 Returns the county.
 
void setCounty (const QString &county)
 Sets the county.
 
QString city () const
 Returns the city.
 
void setCity (const QString &city)
 Sets the city.
 
QString district () const
 Returns the district.
 
void setDistrict (const QString &district)
 Sets the district.
 
QString postalCode () const
 Returns the postal code.
 
void setPostalCode (const QString &postalCode)
 Sets the postalCode.
 
QString street () const
 Returns the street name.
 
void setStreet (const QString &street)
 Sets the street name to street.
 
QString streetNumber () const
 
void setStreetNumber (const QString &streetNumber)
 
bool isEmpty () const
 Returns whether this address is empty.
 
void clear ()
 Clears all of the address' data fields.
 
bool isTextGenerated () const
 Returns true if QGeoAddress::text() is automatically generated from address elements, otherwise returns false if text() has been explicitly assigned.
 

Friends

bool operator== (const QGeoAddress &lhs, const QGeoAddress &rhs)
 Returns true if lhs address is equal to rhs, otherwise returns false.
 
bool operator!= (const QGeoAddress &lhs, const QGeoAddress &rhs)
 Returns true if lhs address is not equal to rhs, otherwise returns false.
 

Related Symbols

(Note that these are not member symbols.)

size_t qHash (const QGeoAddress &address, size_t seed) noexcept
 Returns the hash value for the address, using seed for the calculation.
 

Detailed Description

\inmodule QtPositioning

Since
5.2

The QGeoAddress class represents an address of a \l QGeoLocation.

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 \l text() for displaying purposes and additional properties to access the components of an address:

\list

Definition at line 17 of file qgeoaddress.h.

Constructor & Destructor Documentation

◆ QGeoAddress() [1/3]

QGeoAddress::QGeoAddress ( )

Default constructor.

Definition at line 364 of file qgeoaddress.cpp.

◆ QGeoAddress() [2/3]

QGeoAddress::QGeoAddress ( const QGeoAddress & other)

Constructs a copy of other.

Definition at line 372 of file qgeoaddress.cpp.

◆ QGeoAddress() [3/3]

QGeoAddress::QGeoAddress ( QGeoAddress && other)
defaultnoexcept
Since
6.2

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.

◆ ~QGeoAddress()

QGeoAddress::~QGeoAddress ( )

Destroys this address.

Definition at line 403 of file qgeoaddress.cpp.

Member Function Documentation

◆ city()

QString QGeoAddress::city ( ) const

Returns the city.

Definition at line 543 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sCity.

Referenced by QDeclarativeGeoAddress::city(), setCity(), and QDeclarativeGeoAddress::setCity().

+ Here is the caller graph for this function:

◆ clear()

void QGeoAddress::clear ( )

Clears all of the address' data fields.

Definition at line 670 of file qgeoaddress.cpp.

References QString::clear(), QGeoAddressPrivate::sCity, QGeoAddressPrivate::sCountry, QGeoAddressPrivate::sCountryCode, QGeoAddressPrivate::sCounty, QGeoAddressPrivate::sDistrict, QGeoAddressPrivate::sPostalCode, QGeoAddressPrivate::sState, QGeoAddressPrivate::sStreet, QGeoAddressPrivate::sStreetNumber, and QGeoAddressPrivate::sText.

+ Here is the call graph for this function:

◆ country()

QString QGeoAddress::country ( ) const

Returns the country name.

Definition at line 479 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sCountry.

Referenced by QDeclarativeGeoAddress::country(), setCountry(), and QDeclarativeGeoAddress::setCountry().

+ Here is the caller graph for this function:

◆ countryCode()

QString QGeoAddress::countryCode ( ) const

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

Definition at line 495 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sCountryCode.

Referenced by QDeclarativeGeoAddress::countryCode(), setCountryCode(), and QDeclarativeGeoAddress::setCountryCode().

+ Here is the caller graph for this function:

◆ county()

QString QGeoAddress::county ( ) const

Returns the county.

The county is considered the second subdivision below country.

Definition at line 527 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sCounty.

Referenced by QDeclarativeGeoAddress::county(), setCounty(), and QDeclarativeGeoAddress::setCounty().

+ Here is the caller graph for this function:

◆ district()

QString QGeoAddress::district ( ) const

Returns the district.

The district is considered the subdivison below city.

Definition at line 559 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sDistrict.

Referenced by QDeclarativeGeoAddress::district(), setDistrict(), and QDeclarativeGeoAddress::setDistrict().

+ Here is the caller graph for this function:

◆ isEmpty()

bool QGeoAddress::isEmpty ( ) const

Returns whether this address is empty.

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

Definition at line 652 of file qgeoaddress.cpp.

References QString::isEmpty(), QGeoAddressPrivate::sCity, QGeoAddressPrivate::sCountry, QGeoAddressPrivate::sCountryCode, QGeoAddressPrivate::sCounty, QGeoAddressPrivate::sDistrict, QGeoAddressPrivate::sPostalCode, QGeoAddressPrivate::sState, QGeoAddressPrivate::sStreet, QGeoAddressPrivate::sStreetNumber, and QGeoAddressPrivate::sText.

Referenced by QDeclarativeGeocodeModel::update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isTextGenerated()

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(), setText()

Definition at line 690 of file qgeoaddress.cpp.

References QString::isEmpty(), and QGeoAddressPrivate::sText.

Referenced by QDeclarativeGeoAddress::isTextGenerated(), QDeclarativeGeoAddress::setCity(), QDeclarativeGeoAddress::setCountry(), QDeclarativeGeoAddress::setCountryCode(), QDeclarativeGeoAddress::setCounty(), QDeclarativeGeoAddress::setDistrict(), QDeclarativeGeoAddress::setPostalCode(), QDeclarativeGeoAddress::setState(), QDeclarativeGeoAddress::setStreet(), QDeclarativeGeoAddress::setStreetNumber(), and QDeclarativeGeoAddress::setText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

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

Since
6.2

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.

Definition at line 413 of file qgeoaddress.cpp.

References d.

◆ postalCode()

QString QGeoAddress::postalCode ( ) const

Returns the postal code.

Definition at line 635 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sPostalCode.

Referenced by QDeclarativeGeoAddress::postalCode(), setPostalCode(), and QDeclarativeGeoAddress::setPostalCode().

+ Here is the caller graph for this function:

◆ setCity()

void QGeoAddress::setCity ( const QString & city)

Sets the city.

Definition at line 551 of file qgeoaddress.cpp.

References city(), and QGeoAddressPrivate::sCity.

Referenced by QDeclarativeGeoAddress::setCity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCountry()

void QGeoAddress::setCountry ( const QString & country)

Sets the country name.

Definition at line 487 of file qgeoaddress.cpp.

References country(), and QGeoAddressPrivate::sCountry.

Referenced by QDeclarativeGeoAddress::setCountry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCountryCode()

void QGeoAddress::setCountryCode ( const QString & countryCode)

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

Definition at line 503 of file qgeoaddress.cpp.

References countryCode(), and QGeoAddressPrivate::sCountryCode.

Referenced by QDeclarativeGeoAddress::setCountryCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCounty()

void QGeoAddress::setCounty ( const QString & county)

Sets the county.

Definition at line 535 of file qgeoaddress.cpp.

References county(), and QGeoAddressPrivate::sCounty.

Referenced by QDeclarativeGeoAddress::setCounty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDistrict()

void QGeoAddress::setDistrict ( const QString & district)

Sets the district.

Definition at line 567 of file qgeoaddress.cpp.

References district(), and QGeoAddressPrivate::sDistrict.

Referenced by QDeclarativeGeoAddress::setDistrict().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPostalCode()

void QGeoAddress::setPostalCode ( const QString & postalCode)

Sets the postalCode.

Definition at line 643 of file qgeoaddress.cpp.

References postalCode(), and QGeoAddressPrivate::sPostalCode.

Referenced by QDeclarativeGeoAddress::setPostalCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setState()

void QGeoAddress::setState ( const QString & state)

Sets the state.

Definition at line 519 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sState, and state().

Referenced by QDeclarativeGeoAddress::setState().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStreet()

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
setStreetNumber()

Definition at line 595 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sStreet, and street().

Referenced by RequestHandler::savePlace(), and QDeclarativeGeoAddress::setStreet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStreetNumber()

void QGeoAddress::setStreetNumber ( const QString & streetNumber)
Since
6.2 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.
See also
setStreet()

Definition at line 627 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sStreetNumber, and streetNumber().

Referenced by QDeclarativeGeoAddress::setStreetNumber().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setText()

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.

Definition at line 471 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sText, and text.

Referenced by parseAddressObject(), and QDeclarativeGeoAddress::setText().

+ Here is the caller graph for this function:

◆ state()

QString QGeoAddress::state ( ) const

Returns the state.

The state is considered the first subdivision below country.

Definition at line 511 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sState.

Referenced by setState(), QDeclarativeGeoAddress::setState(), and QDeclarativeGeoAddress::state().

+ Here is the caller graph for this function:

◆ street()

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
streetNumber()

Definition at line 581 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sStreet.

Referenced by setStreet(), QDeclarativeGeoAddress::setStreet(), and QDeclarativeGeoAddress::street().

+ Here is the caller graph for this function:

◆ streetNumber()

QString QGeoAddress::streetNumber ( ) const
Since
6.2 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.
See also
street()

Definition at line 611 of file qgeoaddress.cpp.

References QGeoAddressPrivate::sStreetNumber.

Referenced by setStreetNumber(), QDeclarativeGeoAddress::setStreetNumber(), and QDeclarativeGeoAddress::streetNumber().

+ Here is the caller graph for this function:

◆ swap()

void QGeoAddress::swap ( QGeoAddress & other)
inlinenoexcept

Definition at line 28 of file qgeoaddress.h.

References d, and other().

+ Here is the call graph for this function:

◆ text()

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 \l {QGeoAddress::isTextGenerated()} {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().

Definition at line 456 of file qgeoaddress.cpp.

References formattedAddress(), QString::isEmpty(), and QGeoAddressPrivate::sText.

Referenced by QDeclarativeGeoAddress::setCity(), QDeclarativeGeoAddress::setCountry(), QDeclarativeGeoAddress::setCountryCode(), QDeclarativeGeoAddress::setCounty(), QDeclarativeGeoAddress::setDistrict(), QDeclarativeGeoAddress::setPostalCode(), QDeclarativeGeoAddress::setState(), QDeclarativeGeoAddress::setStreet(), QDeclarativeGeoAddress::setStreetNumber(), QDeclarativeGeoAddress::setText(), and QDeclarativeGeoAddress::text().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

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

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

Definition at line 34 of file qgeoaddress.h.

◆ operator==

bool QGeoAddress::operator== ( const QGeoAddress & lhs,
const QGeoAddress & rhs )
friend

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

Definition at line 30 of file qgeoaddress.h.

◆ qHash()

size_t qHash ( const QGeoAddress & address,
size_t seed )
related

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

Definition at line 728 of file qgeoaddress.cpp.

References hash, qHashMulti(), and seed.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: