KCountry Class
Information about an ISO 3166-1 country. More...
- Header:
#include <KCountry> - CMake:
find_package(KF6 REQUIRED COMPONENTS I18n)
target_link_libraries(mytarget PRIVATE KF6::I18nLocaleData)
List of all members, including inherited members
Properties
- [read-only] alpha2 : QString
- [read-only] alpha3 : QString
- [read-only] currencyCode : QString
- [read-only] emojiFlag : QString
- [read-only] name : QString
- [read-only] subdivisions : QList<KCountrySubdivision>
- [read-only] timeZoneIds : QStringList
Public Functions
- KCountry()
- QString alpha2() const
- QString alpha3() const
- QLocale::Country country() const
- QString currencyCode() const
- QString emojiFlag() const
- bool isValid() const
- QString name() const
- QList<KCountrySubdivision> subdivisions() const
- QList<const char *> timeZoneIds() const
- bool KCountry::operator==(const KCountry &other) const
Static Public Members
- QList<KCountry> allCountries()
- KCountry fromAlpha2(QStringView alpha2Code)
- KCountry fromAlpha2(const char *alpha2Code)
- KCountry fromAlpha3(QStringView alpha3Code)
- KCountry fromAlpha3(const char *alpha3Code)
- KCountry fromLocation(float latitude, float longitude)
- KCountry fromName(QStringView name)
- KCountry fromQLocale(QLocale::Country country)
Detailed Description
The information provided here are aggregated from the following sources:
Note: This requires the iso-codes data files and translation catalogs to be available at runtime.
Property Documentation
[read-only] alpha2 : QString
Access functions:
QStringalpha2() const
[read-only] alpha3 : QString
Access functions:
QStringalpha3() const
[read-only] currencyCode : QString
Access functions:
QStringcurrencyCode() const
[read-only] emojiFlag : QString
Access functions:
QStringemojiFlag() const
[read-only] name : QString
Access functions:
QStringname() const
[read-only] subdivisions : QList<KCountrySubdivision>
Access functions:
QList<KCountrySubdivision> subdivisions() const
[read-only] timeZoneIds : QStringList
Member Function Documentation
KCountry::KCountry()
Creates an invalid/empty KCountry instance. See the fromX() methods for creating a valid instance.
[static] QList<KCountry> KCountry::allCountries()
List all countries.
QString KCountry::alpha2() const
ISO 3166-1 alpha 2 country code.
Note: Getter function for property alpha2.
QString KCountry::alpha3() const
ISO 3166-1 alpha 3 country code.
Note: Getter function for property alpha3.
QLocale::Country KCountry::country() const
Returns the QLocale::Country value matching this country, or QLocale::AnyCountry if there is none.
QString KCountry::currencyCode() const
Currency used in this country as ISO 4217 code.
Note: Getter function for property currencyCode.
QString KCountry::emojiFlag() const
Returns the Unicode flag emoji for this country.
Note: Getter function for property emojiFlag.
[static] KCountry KCountry::fromAlpha2(QStringView alpha2Code)
Create a KCountry instance from an ISO 3166-1 alpha 2 code.
[static] KCountry KCountry::fromAlpha2(const char *alpha2Code)
Create a KCountry instance from an ISO 3166-1 alpha 2 code.
[static] KCountry KCountry::fromAlpha3(QStringView alpha3Code)
Create a KCountry instance from an ISO 3166-1 alpha 3 code.
[static] KCountry KCountry::fromAlpha3(const char *alpha3Code)
Create a KCountry instance from an ISO 3166-1 alpha 3 code.
[static] KCountry KCountry::fromLocation(float latitude, float longitude)
Looks up the country at the given geographic coordinate. This can return an invalid object if the country could not be determined. This can happen in a number of cases:
- on oceans
- in polar regions
- close to a land border
- in disputed territories
[static] KCountry KCountry::fromName(QStringView name)
Attempts to identify the country from the given name. The name can be in any language.
[static] KCountry KCountry::fromQLocale(QLocale::Country country)
Returns a KCountry instance matching the given QLocale::Country code.
bool KCountry::isValid() const
Returns false if this is an empty/invalid/default constructed instance, true otherwise.
QString KCountry::name() const
Translated country name.
Note: Getter function for property name.
QList<KCountrySubdivision> KCountry::subdivisions() const
Highest level of ISO 3166-2 country subdivisions. If there is only one level of subdivisions this lists all of them, for countries with multiple levels, this only includes the top-level subdivisions (ie. those having no parent subdivision).
Note: This can be empty.
Note: Getter function for property subdivisions.
QList<const char *> KCountry::timeZoneIds() const
Timezones in use in this country.