Address QML Type

The Address QML type represents a specific location as a street address. 更多...

import 语句: import QtPositioning

特性

详细描述

An Address is used as a unit of data for queries such as (Reverse) Geocoding or Places searches – many of these operations either accept an Address or return one.

Not all properties of an Address are necessarily available or relevant in all parts of the world and all locales. The district , state and county properties are particularly area-specific for many data sources, and often only one or two of these are available or useful.

The Address has a text property which holds a formatted string. It is the recommended way to display an address to the user and typically takes the format of an address as found on an envelope, but this is not always the case. The text may be automatically generated from constituent address properties such as street , city and and so on, but can also be explicitly assigned. See text 了解细节。

用法范例

The following code snippet shows the declaration of an Address object.

Address {
    id: address
    street: "53 Brandl St"
    city: "Eight Mile Plains"
    country: "Australia"
    countryCode: "AUS"
}
					

This could then be used, for example, as the value of a geocoding query, to get an exact longitude and latitude for the address.

另请参阅 QGeoAddress .

特性文档编制

address : QGeoAddress

For details on how to use this property to interface between C++ and QML see " Interfaces between C++ and QML Code ".

city : string

This property holds the city of the address as a single formatted string.

country : string

This property holds the country of the address as a single formatted string.

countryCode : string

This property holds the country code of the address as a single formatted string.

county : string

This property holds the county of the address as a single formatted string.

district : string

This property holds the district of the address as a single formatted string.

isTextGenerated : bool

This property holds a boolean that if true, indicates that text is automatically generated from address properties. If false, it indicates that the text has been explicitly assigned.

postalCode : string

This property holds the postal code of the address as a single formatted string.

state : string

This property holds the state of the address as a single formatted string.

street : string

This property holds the street of the address.

注意: Before Qt6 this property could also contain things like a unit number, a building name, or anything else that might be used to distinguish one address from another. Since Qt6 use streetNumber property for such information.

streetNumber : string [since QtPositioning 6.2]

This property holds the street number of the address like a unit number, a building name, or anything else that might be used to distinguish one address from another.

This property was introduced in QtPositioning 6.2.

text : string

This property holds 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 assigned to text ,那么 isTextGenerated will be set to true and text will return a string which is locally formatted according to countryCode and based on the properties of the address. Modifying the address properties such as street , city and so on may cause the contents of text to change.

If a non-empty string is assigned to text ,那么 isTextGenerated will be set to false and text will always return the explicitly assigned string. Modifying address properties will not affect the text 特性。