Files
RedBear-OS/local/recipes/kde/kf6-ki18n/source/docs/locale-data-qml-api.md
T
2026-04-14 10:51:06 +01:00

2.3 KiB

Locale Data QML API

Data Types

The basic types providing locale data in the C++ API are also available in QML as Q_GADGETs and offer the same properties in QML:

\li KCountry \li KCountrySubdivision

Country Lookup

The static country lookup methods found in KCountry in the C++ API are available from the Country singleton in QML, as part of the org.kde.i18n.localeData module.

Listing all

For listing all known countries there is the Country.allCountries property, providing a list of KCountry objects.

import org.kde.i18n.localeData 1.0

... {
    ComboBox {
        model: Country.allCountries
        displayText: currentValue.emojiFlag + " " + currentValue.name
    }
}

Lookup by code, name or location

The following methods allow to obtain a KCountry object:

\li Country.fromAlpha2 \li Country.fromAlpha3 \li Country.fromName \li Country.fromLocation

See the corresponding C++ API with the same name in KCountry for further details.

Country Subdivision Lookup

The static country subdivision lookup methods found in KCountrySubdivision in the C++ API are available from the CountrySubdivision singleton in QML, as part of the org.kde.i18n.localeData module.

The following methods allow to obtain a KCountrySubdivision object:

\li CountrySubdivision.fromCode \li CountrySubdivision.fromLocation

See the corresponding C++ API with the same name in KCountrySubdivision for further details.

Timezone Lookup

The static country timezone lookup methods found in KTimeZone in the C++ API are available from the TimeZone singleton in QML, as part of the org.kde.i18n.localeData module.

The following methods are provided:

\li TimeZone.country \li TimeZone.fromLocation

See the corresponding C++ API with the same name in KTimeZone for further details.

Further References

There's a standalone QML example showing most of the above mentioned functionality in tests/demo.qml provided as part of the KI18n source code.