QGeoAddress 类

QGeoAddress 类表示地址为 QGeoLocation . 更多...

头: #include <QGeoAddress>
CMake: find_package(Qt6 COMPONENTS Positioning REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning
Since: Qt 5.2

公共函数

  QGeoAddress (QGeoAddress && other )
  QGeoAddress (const QGeoAddress & other )
  QGeoAddress ()
QGeoAddress & operator= (QGeoAddress & other )
QGeoAddress & operator= (const QGeoAddress & address )
  ~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 )
void setStreetNumber (const QString & streetNumber )
void setText (const QString & text )
QString state () const
QString street () const
QString streetNumber () const
QString text () const
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 )

详细描述

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:

成员函数文档编制

[since 6.2] QGeoAddress:: QGeoAddress ( QGeoAddress && other )

Constructs a geo address object by moving from other .

注意: 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.

该函数在 Qt 6.2 引入。

QGeoAddress:: QGeoAddress (const QGeoAddress & other )

构造副本为 other .

QGeoAddress:: QGeoAddress ()

默认构造函数。

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

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

注意: 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.

该函数在 Qt 6.2 引入。

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

赋值给定 address to this address and returns a reference to this address.

QGeoAddress:: ~QGeoAddress ()

销毁此地址。

QString QGeoAddress:: city () const

返回城市。

另请参阅 setCity ().

void QGeoAddress:: clear ()

Clears all of the address' data fields.

QString QGeoAddress:: country () const

返回国家名称。

另请参阅 setCountry ().

QString QGeoAddress:: countryCode () const

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

另请参阅 setCountryCode ().

QString QGeoAddress:: county () const

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

另请参阅 setCounty ().

QString QGeoAddress:: district () const

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

另请参阅 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

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

另请参阅 text () 和 setText ().

QString QGeoAddress:: postalCode () const

Returns the postal code.

另请参阅 setPostalCode ().

void QGeoAddress:: setCity (const QString & city )

设置 city .

另请参阅 city ().

void QGeoAddress:: setCountry (const QString & country )

设置 country 名称。

另请参阅 country ().

void QGeoAddress:: setCountryCode (const QString & countryCode )

设置 countryCode according to ISO 3166-1 alpha-3

另请参阅 countryCode ().

void QGeoAddress:: setCounty (const QString & county )

设置 county .

另请参阅 county ().

void QGeoAddress:: setDistrict (const QString & district )

设置 district .

另请参阅 district ().

void QGeoAddress:: setPostalCode (const QString & postalCode )

设置 postalCode .

另请参阅 postalCode ().

void QGeoAddress:: setState (const QString & state )

设置 state .

另请参阅 state ().

void QGeoAddress:: setStreet (const QString & street )

Sets the street name to street .

注意: 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.

另请参阅 street () 和 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.

注意: Before Qt6 this information was set by setStreet () 方法。

该函数在 Qt 6.2 引入。

另请参阅 streetNumber () 和 setStreet ().

void QGeoAddress:: setText (const QString & text )

text is not empty, explicitly assigns text as the string to be returned by text (). isTextGenerated () 将返回 false。

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

另请参阅 text ().

QString QGeoAddress:: state () const

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

另请参阅 setState ().

QString QGeoAddress:: street () const

Returns the street name.

注意: 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.

另请参阅 setStreet () 和 streetNumber ().

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

返回街道编号。

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.

注意: Before Qt6 this information was returned by street () 方法。

该函数在 Qt 6.2 引入。

另请参阅 setStreetNumber () 和 street ().

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 (),然后 isTextGenerated () 会被设为 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 (),然后 isTextGenerated () 会被设为 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().

另请参阅 setText ().

相关非成员

size_t qHash (const QGeoAddress & address , size_t seed = 0)

返回哈希值为 address ,使用 seed for the calculation.

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

返回 true if lhs address is not equal to rhs ,否则返回 false .

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

返回 true if lhs address is equal to rhs ,否则返回 false .