QGeoAddress Class
The QGeoAddress class represents an address of a QGeoLocation. 更多...
头文件: | #include <QGeoAddress> |
qmake: | QT += positioning |
开始支持版本: | Qt 5.2 |
公有函数
QGeoAddress() | |
QGeoAddress(const 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) |
void | setText(const QString &text) |
QString | state() const |
QString | street() const |
QString | text() const |
bool | operator!=(const QGeoAddress &other) const |
QGeoAddress & | operator=(const QGeoAddress &address) |
bool | operator==(const QGeoAddress &other) const |
详细描述
The QGeoAddress class represents an address of a 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 text() for displaying purposes and additional properties to access the components of an address:
成员函数
QGeoAddress::QGeoAddress()
Default constructor.
QGeoAddress::QGeoAddress(const QGeoAddress &other)
Constructs a copy of other.
QGeoAddress::~QGeoAddress()
Destroys this address.
QString QGeoAddress::city() const
Returns the city.
参见 setCity().
void QGeoAddress::clear()
Clears all of the address' data fields.
QString QGeoAddress::country() const
Returns the country name.
参见 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
Returns true if QGeoAddress::text() is automatically generated from address elements, otherwise returns false if text() has been explicitly assigned.
QString QGeoAddress::postalCode() const
Returns the postal code.
参见 setPostalCode().
void QGeoAddress::setCity(const QString &city)
Sets the city.
参见 city().
void QGeoAddress::setCountry(const QString &country)
Sets the country name.
参见 country().
void QGeoAddress::setCountryCode(const QString &countryCode)
Sets the countryCode according to ISO 3166-1 alpha-3
参见 countryCode().
void QGeoAddress::setCounty(const QString &county)
Sets the county.
参见 county().
void QGeoAddress::setDistrict(const QString &district)
Sets the district.
参见 district().
void QGeoAddress::setPostalCode(const QString &postalCode)
Sets the postalCode.
参见 postalCode().
void QGeoAddress::setState(const QString &state)
Sets the state.
参见 state().
void QGeoAddress::setStreet(const QString &street)
Sets the street-level component of the address to street.
This typically includes a street number and street name but may also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another.
参见 street().
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.
参见 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-level component of the address.
This typically includes a street number and street name but may also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another.
参见 setStreet().
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().
参见 setText().
bool QGeoAddress::operator!=(const QGeoAddress &other) const
Returns true if this address is not equal to other, otherwise returns false.
QGeoAddress &QGeoAddress::operator=(const QGeoAddress &address)
Assigns the given address to this address and returns a reference to this address.
bool QGeoAddress::operator==(const QGeoAddress &other) const
Returns true if this address is equal to other, otherwise returns false.