QLocale Class

The QLocale class converts between numbers and their string representations in various languages. More...

Header: #include <QLocale>
qmake: QT += core

Note: All functions in this class are reentrant with the following exceptions:

Public Types

enum Country { AnyCountry, Afghanistan, AlandIslands, Albania, Algeria, 鈥�, Zimbabwe }
enum CurrencySymbolFormat { CurrencyIsoCode, CurrencySymbol, CurrencyDisplayName }
enum DataSizeFormat { DataSizeIecFormat, DataSizeTraditionalFormat, DataSizeSIFormat }
flags DataSizeFormats
enum FloatingPointPrecisionOption { FloatingPointShortest }
enum FormatType { LongFormat, ShortFormat, NarrowFormat }
enum Language { AnyLanguage, C, Abkhazian, Afan, Afar, 鈥�, Zulu }
enum MeasurementSystem { MetricSystem, ImperialUSSystem, ImperialUKSystem, ImperialSystem }
enum NumberOption { DefaultNumberOptions, OmitGroupSeparator, RejectGroupSeparator, OmitLeadingZeroInExponent, RejectLeadingZeroInExponent, 鈥�, RejectTrailingZeroesAfterDot }
flags NumberOptions
enum QuotationStyle { StandardQuotation, AlternateQuotation }
enum Script { AnyScript, AdlamScript, AhomScript, AnatolianHieroglyphsScript, ArabicScript, 鈥�, YiScript }

Public Functions

QLocale(const QLocale &other)
QLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)
QLocale(QLocale::Language language, QLocale::Country country = AnyCountry)
QLocale(const QString &name)
QLocale()
QLocale &operator=(const QLocale &other)
~QLocale()
QString amText() const
QString bcp47Name() const
QLocale collation() const
QLocale::Country country() const
QString createSeparatedList(const QStringList &list) const
QString currencySymbol(QLocale::CurrencySymbolFormat format = CurrencySymbol) const
QString dateFormat(QLocale::FormatType format = LongFormat) const
QString dateTimeFormat(QLocale::FormatType format = LongFormat) const
QString dayName(int day, QLocale::FormatType type = LongFormat) const
QChar decimalPoint() const
QChar exponential() const
Qt::DayOfWeek firstDayOfWeek() const
QString formattedDataSize(qint64 bytes, int precision = 2, QLocale::DataSizeFormats format = DataSizeIecFormat) const
QChar groupSeparator() const
QLocale::Language language() const
QLocale::MeasurementSystem measurementSystem() const
QString monthName(int month, QLocale::FormatType type = LongFormat) const
QString name() const
QString nativeCountryName() const
QString nativeLanguageName() const
QChar negativeSign() const
QLocale::NumberOptions numberOptions() const
QChar percent() const
QString pmText() const
QChar positiveSign() const
QString quoteString(const QString &str, QLocale::QuotationStyle style = StandardQuotation) const
QString quoteString(const QStringRef &str, QLocale::QuotationStyle style = StandardQuotation) const
QLocale::Script script() const
void setNumberOptions(QLocale::NumberOptions options)
QString standaloneDayName(int day, QLocale::FormatType type = LongFormat) const
QString standaloneMonthName(int month, QLocale::FormatType type = LongFormat) const
void swap(QLocale &other)
Qt::LayoutDirection textDirection() const
QString timeFormat(QLocale::FormatType format = LongFormat) const
QString toCurrencyString(qlonglong value, const QString &symbol = QString()) const
QString toCurrencyString(qulonglong value, const QString &symbol = QString()) const
QString toCurrencyString(short value, const QString &symbol = QString()) const
QString toCurrencyString(ushort value, const QString &symbol = QString()) const
QString toCurrencyString(int value, const QString &symbol = QString()) const
QString toCurrencyString(uint value, const QString &symbol = QString()) const
QString toCurrencyString(double value, const QString &symbol = QString()) const
QString toCurrencyString(double value, const QString &symbol, int precision) const
QString toCurrencyString(float value, const QString &symbol = QString()) const
QString toCurrencyString(float i, const QString &symbol, int precision) const
QDate toDate(const QString &string, QLocale::FormatType format = LongFormat) const
QDate toDate(const QString &string, const QString &format) const
QDate toDate(const QString &string, QLocale::FormatType format, QCalendar cal) const
QDate toDate(const QString &string, const QString &format, QCalendar cal) const
QDateTime toDateTime(const QString &string, QLocale::FormatType format = LongFormat) const
QDateTime toDateTime(const QString &string, const QString &format) const
QDateTime toDateTime(const QString &string, QLocale::FormatType format, QCalendar cal) const
QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const
double toDouble(const QString &s, bool *ok = nullptr) const
double toDouble(const QStringRef &s, bool *ok = nullptr) const
double toDouble(QStringView s, bool *ok = nullptr) const
float toFloat(const QString &s, bool *ok = nullptr) const
float toFloat(const QStringRef &s, bool *ok = nullptr) const
float toFloat(QStringView s, bool *ok = nullptr) const
int toInt(const QString &s, bool *ok = nullptr) const
int toInt(const QStringRef &s, bool *ok = nullptr) const
int toInt(QStringView s, bool *ok = nullptr) const
long toLong(const QString &s, bool *ok = nullptr) const
long toLong(const QStringRef &s, bool *ok = nullptr) const
long toLong(QStringView s, bool *ok = nullptr) const
qlonglong toLongLong(const QString &s, bool *ok = nullptr) const
qlonglong toLongLong(const QStringRef &s, bool *ok = nullptr) const
qlonglong toLongLong(QStringView s, bool *ok = nullptr) const
QString toLower(const QString &str) const
short toShort(const QString &s, bool *ok = nullptr) const
short toShort(const QStringRef &s, bool *ok = nullptr) const
short toShort(QStringView s, bool *ok = nullptr) const
QString toString(qlonglong i) const
QString toString(qulonglong i) const
QString toString(long i) const
QString toString(ulong i) const
QString toString(short i) const
QString toString(ushort i) const
QString toString(int i) const
QString toString(uint i) const
QString toString(double i, char f = 'g', int prec = 6) const
QString toString(float i, char f = ..., int prec = ...) const
QString toString(const QDate &date, const QString &format) const
QString toString(const QTime &time, const QString &format) const
QString toString(const QDateTime &dateTime, const QString &format) const
QString toString(const QDate &date, QStringView format) const
QString toString(const QTime &time, QStringView format) const
QString toString(const QDateTime &dateTime, QStringView format) const
QString toString(const QDate &date, QLocale::FormatType format = LongFormat) const
QString toString(const QTime &time, QLocale::FormatType format = LongFormat) const
QString toString(const QDateTime &dateTime, QLocale::FormatType format = LongFormat) const
QTime toTime(const QString &string, QLocale::FormatType format = LongFormat) const
QTime toTime(const QString &string, const QString &format) const
QTime toTime(const QString &string, QLocale::FormatType format, QCalendar cal) const
QTime toTime(const QString &string, const QString &format, QCalendar cal) const
uint toUInt(const QString &s, bool *ok = nullptr) const
uint toUInt(const QStringRef &s, bool *ok = nullptr) const
uint toUInt(QStringView s, bool *ok = nullptr) const
ulong toULong(const QString &s, bool *ok = nullptr) const
ulong toULong(const QStringRef &s, bool *ok = nullptr) const
ulong toULong(QStringView s, bool *ok = nullptr) const
qulonglong toULongLong(const QString &s, bool *ok = nullptr) const
qulonglong toULongLong(const QStringRef &s, bool *ok = nullptr) const
qulonglong toULongLong(QStringView s, bool *ok = nullptr) const
ushort toUShort(const QString &s, bool *ok = nullptr) const
ushort toUShort(const QStringRef &s, bool *ok = nullptr) const
ushort toUShort(QStringView s, bool *ok = nullptr) const
QString toUpper(const QString &str) const
QStringList uiLanguages() const
QList<Qt::DayOfWeek> weekdays() const
QChar zeroDigit() const
bool operator!=(const QLocale &other) const
bool operator==(const QLocale &other) const

Static Public Members

QLocale c()
QString countryToString(QLocale::Country country)
QString languageToString(QLocale::Language language)
QList<QLocale> matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country)
QString scriptToString(QLocale::Script script)
void setDefault(const QLocale &locale)
QLocale system()
uint qHash(const QLocale &key, uint seed = 0)

Detailed Description

QLocale is initialized with a language/country pair in its constructor and offers number-to-string and string-to-number conversion functions similar to those in QString.

Example:

QLocale egyptian(QLocale::Arabic, QLocale::Egypt);
QString s1 = egyptian.toString(1.571429E+07, 'e');
QString s2 = egyptian.toString(10);

double d = egyptian.toDouble(s1);
int i = egyptian.toInt(s2);

QLocale supports the concept of a default locale, which is determined from the system's locale settings at application startup. The default locale can be changed by calling the static member setDefault(). Setting the default locale has the following effects:

  • If a QLocale object is constructed with the default constructor, it will use the default locale's settings.
  • QString::toInt(), QString::toDouble(), etc., interpret the string according to the default locale. If this fails, it falls back on the "C" locale.
  • QString::arg() uses the default locale to format a number when its position specifier in the format string contains an 'L', e.g. "%L1".

The following example illustrates how to use QLocale directly:

QLocale::setDefault(QLocale(QLocale::Hebrew, QLocale::Israel));
QLocale hebrew; // Constructs a default QLocale
QString s1 = hebrew.toString(15714.3, 'e');

bool ok;
double d;

QLocale::setDefault(QLocale::C);
d = QString("1234,56").toDouble(&ok);   // ok == false
d = QString("1234.56").toDouble(&ok);   // ok == true, d == 1234.56

QLocale::setDefault(QLocale::German);
d = QString("1234,56").toDouble(&ok);   // ok == true, d == 1234.56
d = QString("1234.56").toDouble(&ok);   // ok == true, d == 1234.56

QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
str = QString("%1 %L2 %L3")
      .arg(12345).arg(12345).arg(12345, 0, 16);
// str == "12345 12,345 3039"

When a language/country pair is specified in the constructor, one of three things can happen:

  • If the language/country pair is found in the database, it is used.
  • If the language is found but the country is not, or if the country is AnyCountry, the language is used with the most appropriate available country (for example, Germany for German),
  • If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).

Use language() and country() to determine the actual language and country values used.

An alternative method for constructing a QLocale object is by specifying the locale name.

QLocale korean("ko");
QLocale swiss("de_CH");

This constructor converts the locale name to a language/country pair; it does not use the system locale database.

Note: For the current keyboard input locale take a look at QInputMethod::locale().

QLocale's data is based on Common Locale Data Repository v36.

See also QString::arg(), QString::toInt(), QString::toDouble(), and QInputMethod::locale().

Member Type Documentation

enum QLocale::Country

This enumerated type is used to specify a country.

ConstantValueDescription
QLocale::AnyCountry0聽
QLocale::Afghanistan1聽
QLocale::AlandIslands248聽
QLocale::Albania2聽
QLocale::Algeria3聽
QLocale::AmericanSamoa4聽
QLocale::Andorra5聽
QLocale::Angola6聽
QLocale::Anguilla7聽
QLocale::Antarctica8聽
QLocale::AntiguaAndBarbuda9聽
QLocale::Argentina10聽
QLocale::Armenia11聽
QLocale::Aruba12聽
QLocale::AscensionIsland247聽
QLocale::Australia13聽
QLocale::Austria14聽
QLocale::Azerbaijan15聽
QLocale::Bahamas16聽
QLocale::Bahrain17聽
QLocale::Bangladesh18聽
QLocale::Barbados19聽
QLocale::Belarus20聽
QLocale::Belgium21聽
QLocale::Belize22聽
QLocale::Benin23聽
QLocale::Bermuda24聽
QLocale::Bhutan25聽
QLocale::Bolivia26聽
QLocale::Bonaire255聽
QLocale::BosniaAndHerzegowina27聽
QLocale::Botswana28聽
QLocale::BouvetIsland29聽
QLocale::Brazil30聽
QLocale::BritishIndianOceanTerritory31聽
QLocale::BritishVirginIslands233聽
QLocale::Brunei32聽
QLocale::Bulgaria33聽
QLocale::BurkinaFaso34聽
QLocale::Burundi35聽
QLocale::Cambodia36聽
QLocale::Cameroon37聽
QLocale::Canada38聽
QLocale::CanaryIslands238聽
QLocale::CapeVerde39聽
QLocale::CaymanIslands40聽
QLocale::CentralAfricanRepublic41聽
QLocale::CeutaAndMelilla250聽
QLocale::Chad42聽
QLocale::Chile43聽
QLocale::China44聽
QLocale::ChristmasIsland45聽
QLocale::ClippertonIsland241聽
QLocale::CocosIslands46聽
QLocale::Colombia47聽
QLocale::Comoros48聽
QLocale::CongoBrazzaville50聽
QLocale::CongoKinshasa49聽
QLocale::CookIslands51聽
QLocale::CostaRica52聽
QLocale::Croatia54聽
QLocale::Cuba55聽
QLocale::CuraSao152聽
QLocale::Cyprus56聽
QLocale::CzechRepublic57聽
QLocale::DemocraticRepublicOfCongoCongoKinshasaObsolete, please use CongoKinshasa
QLocale::DemocraticRepublicOfKoreaNorthKoreaObsolete, please use NorthKorea
QLocale::Denmark58聽
QLocale::DiegoGarcia249聽
QLocale::Djibouti59聽
QLocale::Dominica60聽
QLocale::DominicanRepublic61聽
QLocale::EastTimor62聽
QLocale::Ecuador63聽
QLocale::Egypt64聽
QLocale::ElSalvador65聽
QLocale::EquatorialGuinea66聽
QLocale::Eritrea67聽
QLocale::Estonia68聽
QLocale::Ethiopia69聽
QLocale::EuropeanUnion258Since Qt 5.7
QLocale::Europe261Since Qt 5.12
QLocale::FalklandIslands70聽
QLocale::FaroeIslands71聽
QLocale::Fiji72聽
QLocale::Finland73聽
QLocale::France74聽
QLocale::FrenchGuiana76聽
QLocale::FrenchPolynesia77聽
QLocale::FrenchSouthernTerritories78聽
QLocale::Gabon79聽
QLocale::Gambia80聽
QLocale::Georgia81聽
QLocale::Germany82聽
QLocale::Ghana83聽
QLocale::Gibraltar84聽
QLocale::Greece85聽
QLocale::Greenland86聽
QLocale::Grenada87聽
QLocale::Guadeloupe88聽
QLocale::Guam89聽
QLocale::Guatemala90聽
QLocale::Guernsey75聽
QLocale::Guinea91聽
QLocale::GuineaBissau92聽
QLocale::Guyana93聽
QLocale::Haiti94聽
QLocale::HeardAndMcDonaldIslands95聽
QLocale::Honduras96聽
QLocale::HongKong97聽
QLocale::Hungary98聽
QLocale::Iceland99聽
QLocale::India100聽
QLocale::Indonesia101聽
QLocale::Iran102聽
QLocale::Iraq103聽
QLocale::Ireland104聽
QLocale::IsleOfMan251聽
QLocale::Israel105聽
QLocale::Italy106聽
QLocale::IvoryCoast53聽
QLocale::Jamaica107聽
QLocale::Japan108聽
QLocale::Jersey252聽
QLocale::Jordan109聽
QLocale::Kazakhstan110聽
QLocale::Kenya111聽
QLocale::Kiribati112聽
QLocale::Kosovo257Since Qt 5.2
QLocale::Kuwait115聽
QLocale::Kyrgyzstan116聽
QLocale::Laos117聽
QLocale::LatinAmerica246聽
QLocale::LatinAmericaAndTheCaribbeanLatinAmericaObsolete, please use LatinAmerica
QLocale::Latvia118聽
QLocale::Lebanon119聽
QLocale::Lesotho120聽
QLocale::Liberia121聽
QLocale::Libya122聽
QLocale::Liechtenstein123聽
QLocale::Lithuania124聽
QLocale::Luxembourg125聽
QLocale::Macau126聽
QLocale::Macedonia127聽
QLocale::Madagascar128聽
QLocale::Malawi129聽
QLocale::Malaysia130聽
QLocale::Maldives131聽
QLocale::Mali132聽
QLocale::Malta133聽
QLocale::MarshallIslands134聽
QLocale::Martinique135聽
QLocale::Mauritania136聽
QLocale::Mauritius137聽
QLocale::Mayotte138聽
QLocale::Mexico139聽
QLocale::Micronesia140聽
QLocale::Moldova141聽
QLocale::Monaco142聽
QLocale::Mongolia143聽
QLocale::Montenegro242聽
QLocale::Montserrat144聽
QLocale::Morocco145聽
QLocale::Mozambique146聽
QLocale::Myanmar147聽
QLocale::Namibia148聽
QLocale::NauruCountry149聽
QLocale::Nepal150聽
QLocale::Netherlands151聽
QLocale::NewCaledonia153聽
QLocale::NewZealand154聽
QLocale::Nicaragua155聽
QLocale::Niger156聽
QLocale::Nigeria157聽
QLocale::Niue158聽
QLocale::NorfolkIsland159聽
QLocale::NorthernMarianaIslands160聽
QLocale::NorthKorea113聽
QLocale::Norway161聽
QLocale::Oman162聽
QLocale::OutlyingOceania259Since Qt 5.7
QLocale::Pakistan163聽
QLocale::Palau164聽
QLocale::PalestinianTerritories165聽
QLocale::Panama166聽
QLocale::PapuaNewGuinea167聽
QLocale::Paraguay168聽
QLocale::PeoplesRepublicOfCongoCongoBrazzavilleObsolete, please use CongoBrazzaville
QLocale::Peru169聽
QLocale::Philippines170聽
QLocale::Pitcairn171聽
QLocale::Poland172聽
QLocale::Portugal173聽
QLocale::PuertoRico174聽
QLocale::Qatar175聽
QLocale::RepublicOfKoreaSouthKoreaObsolete, please use SouthKorea
QLocale::Reunion176聽
QLocale::Romania177聽
QLocale::RussianFederationRussiasame as Russia
QLocale::Russia178same as RussianFederation
QLocale::Rwanda179聽
QLocale::SaintBarthelemy244聽
QLocale::SaintHelena199聽
QLocale::SaintKittsAndNevis180聽
QLocale::SaintLucia181聽
QLocale::SaintMartin245聽
QLocale::SaintPierreAndMiquelon200聽
QLocale::SaintVincentAndTheGrenadines182聽
QLocale::Samoa183聽
QLocale::SanMarino184聽
QLocale::SaoTomeAndPrincipe185聽
QLocale::SaudiArabia186聽
QLocale::Senegal187聽
QLocale::Serbia243聽
QLocale::Seychelles188聽
QLocale::SierraLeone189聽
QLocale::Singapore190聽
QLocale::SintMaarten256聽
QLocale::Slovakia191聽
QLocale::Slovenia192聽
QLocale::SolomonIslands193聽
QLocale::Somalia194聽
QLocale::SouthAfrica195聽
QLocale::SouthGeorgiaAndTheSouthSandwichIslands196聽
QLocale::SouthKorea114聽
QLocale::SouthSudan254聽
QLocale::Spain197聽
QLocale::SriLanka198聽
QLocale::Sudan201聽
QLocale::Suriname202聽
QLocale::SvalbardAndJanMayenIslands203聽
QLocale::Swaziland204聽
QLocale::Sweden205聽
QLocale::Switzerland206聽
QLocale::Syria207聽
QLocale::SyrianArabRepublicSyriaObsolete, please use Syria
QLocale::Taiwan208聽
QLocale::Tajikistan209聽
QLocale::Tanzania210聽
QLocale::Thailand211聽
QLocale::Togo212聽
QLocale::TokelauCountry213聽
QLocale::TokelauTokelauCountryObsolete, please use TokelauCountry
QLocale::Tonga214聽
QLocale::TrinidadAndTobago215聽
QLocale::TristanDaCunha253聽
QLocale::Tunisia216聽
QLocale::Turkey217聽
QLocale::Turkmenistan218聽
QLocale::TurksAndCaicosIslands219聽
QLocale::TuvaluCountry220聽
QLocale::TuvaluTuvaluCountryObsolete, please use TuvaluCountry
QLocale::Uganda221聽
QLocale::Ukraine222聽
QLocale::UnitedArabEmirates223聽
QLocale::UnitedKingdom224聽
QLocale::UnitedStates225聽
QLocale::UnitedStatesMinorOutlyingIslands226聽
QLocale::UnitedStatesVirginIslands234聽
QLocale::Uruguay227聽
QLocale::Uzbekistan228聽
QLocale::Vanuatu229聽
QLocale::VaticanCityState230聽
QLocale::Venezuela231聽
QLocale::Vietnam232聽
QLocale::WallisAndFutunaIslands235聽
QLocale::WesternSahara236聽
QLocale::World260Since Qt 5.12
QLocale::Yemen237聽
QLocale::Zambia239聽
QLocale::Zimbabwe240聽

See also country() and countryToString().

enum QLocale::CurrencySymbolFormat

Specifies the format of the currency symbol.

ConstantValueDescription
QLocale::CurrencyIsoCode0a ISO-4217 code of the currency.
QLocale::CurrencySymbol1a currency symbol.
QLocale::CurrencyDisplayName2a user readable name of the currency.

This enum was introduced or modified in Qt 4.8.

enum QLocale::DataSizeFormat
flags QLocale::DataSizeFormats

Specifies the format for representation of data quantities.

ConstantValueDescription
QLocale::DataSizeIecFormat0format using base 1024 and IEC prefixes: KiB, MiB, GiB, ...
QLocale::DataSizeTraditionalFormatDataSizeSIQuantifiersformat using base 1024 and SI prefixes: kB, MB, GB, ...
QLocale::DataSizeSIFormatDataSizeBase1000 | DataSizeSIQuantifiersformat using base 1000 and SI prefixes: kB, MB, GB, ...

This enum was introduced or modified in Qt 5.10.

The DataSizeFormats type is a typedef for QFlags<DataSizeFormat>. It stores an OR combination of DataSizeFormat values.

See also formattedDataSize().

enum QLocale::FloatingPointPrecisionOption

This enum defines constants that can be given as precision to QString::number(), QByteArray::number(), and QLocale::toString() when converting floats or doubles, in order to express a variable number of digits as precision.

ConstantValueDescription
QLocale::FloatingPointShortest-128The conversion algorithm will try to find the shortest accurate representation for the given number. "Accurate" means that you get the exact same number back from an inverse conversion on the generated string representation.

This enum was introduced or modified in Qt 5.7.

See also toString(), QString, and QByteArray.

enum QLocale::FormatType

This enum describes the types of format that can be used when converting QDate and QTime objects to strings.

ConstantValueDescription
QLocale::LongFormat0The long version of day and month names; for example, returning "January" as a month name.
QLocale::ShortFormat1The short version of day and month names; for example, returning "Jan" as a month name.
QLocale::NarrowFormat2A special version of day and month names for use when space is limited; for example, returning "J" as a month name. Note that the narrow format might contain the same text for different months and days or it can even be an empty string if the locale doesn't support narrow names, so you should avoid using it for date formatting. Also, for the system locale this format is the same as ShortFormat.

See also QDateTime::toString(), QDate::toString(), and QTime::toString().

enum QLocale::Language

This enumerated type is used to specify a language.

ConstantValueDescription
QLocale::AnyLanguage0聽
QLocale::C1A simplified English locale; see QLocale::c()
QLocale::Abkhazian2聽
QLocale::AfanOromoObsolete, please use Oromo
QLocale::Afar4聽
QLocale::Afrikaans5聽
QLocale::Aghem237聽
QLocale::Ahom340Since Qt 5.7
QLocale::Akan146聽
QLocale::Akkadian262Since Qt 5.1
QLocale::Akoose312Since Qt 5.3
QLocale::Albanian6聽
QLocale::AmericanSignLanguage341Since Qt 5.7
QLocale::Amharic7聽
QLocale::AncientEgyptian263Since Qt 5.1
QLocale::AncientGreek264Since Qt 5.1
QLocale::AncientNorthArabian331Since Qt 5.5
QLocale::Arabic8聽
QLocale::Aragonese261Since Qt 5.1
QLocale::Aramaic265Since Qt 5.1
QLocale::ArdhamagadhiPrakrit342Since Qt 5.7
QLocale::Armenian9聽
QLocale::Assamese10聽
QLocale::Asturian256聽
QLocale::Asu205聽
QLocale::Atsam156聽
QLocale::Avaric216聽
QLocale::Avestan255聽
QLocale::Aymara11聽
QLocale::Azerbaijani12聽
QLocale::Bafia243聽
QLocale::Balinese266Since Qt 5.1
QLocale::Bambara188聽
QLocale::Bamun267Since Qt 5.1
QLocale::Basaa238聽
QLocale::Bashkir13聽
QLocale::Basque14聽
QLocale::Bassa336Since Qt 5.5
QLocale::BatakToba268Since Qt 5.1
QLocale::Belarusian22聽
QLocale::Bemba195聽
QLocale::Bena186聽
QLocale::Bengali15聽
QLocale::Bhojpuri343Since Qt 5.7
QLocale::BhutaniDzongkhaObsolete, please use Dzongkha
QLocale::Bihari17聽
QLocale::Bislama18聽
QLocale::Blin152聽
QLocale::Bodo215聽
QLocale::Bosnian142聽
QLocale::Breton19聽
QLocale::Buginese269Since Qt 5.1
QLocale::Buhid270Since Qt 5.1
QLocale::Bulgarian20聽
QLocale::Burmese21聽
QLocale::ByelorussianBelarusianObsolete, please use Belarusian
QLocale::CambodianKhmerObsolete, please use Khmer
QLocale::Cantonese357Since Qt 5.7
QLocale::Carian271Since Qt 5.1
QLocale::Catalan24聽
QLocale::Cebuano365Since Qt 5.14
QLocale::CentralKurdish316Since Qt 5.5
QLocale::CentralMoroccoTamazight212聽
QLocale::Chakma272Since Qt 5.1
QLocale::Chamorro217聽
QLocale::Chechen218聽
QLocale::Cherokee190聽
QLocale::ChewaNyanjaObsolete, please use Nyanja
QLocale::Chickasaw367Since Qt 5.14
QLocale::Chiga211聽
QLocale::Chinese25(Mandarin)
QLocale::Church219聽
QLocale::Chuvash220聽
QLocale::ClassicalMandaic273Since Qt 5.1
QLocale::Colognian201聽
QLocale::CongoSwahili250聽
QLocale::Coptic274Since Qt 5.1
QLocale::Cornish145聽
QLocale::Corsican26聽
QLocale::Cree221聽
QLocale::Croatian27聽
QLocale::Czech28聽
QLocale::Danish29聽
QLocale::Divehi143聽
QLocale::Dogri275Since Qt 5.1
QLocale::Duala240聽
QLocale::Dutch30聽
QLocale::Dzongkha16聽
QLocale::EasternCham276Since Qt 5.1
QLocale::EasternKayah277Since Qt 5.1
QLocale::Embu189聽
QLocale::English31聽
QLocale::Erzya366Since Qt 5.14
QLocale::Esperanto32聽
QLocale::Estonian33聽
QLocale::Etruscan278Since Qt 5.1
QLocale::Ewe161聽
QLocale::Ewondo242聽
QLocale::Faroese34聽
QLocale::Fijian35聽
QLocale::Filipino166聽
QLocale::Finnish36聽
QLocale::French37聽
QLocale::FrisianWesternFrisiansame as WesternFrisian
QLocale::Friulian159聽
QLocale::Fulah177聽
QLocale::Ga148聽
QLocale::Gaelic39聽
QLocale::Galician40聽
QLocale::Ganda194聽
QLocale::Geez153聽
QLocale::Georgian41聽
QLocale::German42聽
QLocale::Gothic279Since Qt 5.1
QLocale::Greek43聽
QLocale::Greenlandic44聽
QLocale::Guarani45聽
QLocale::Gujarati46聽
QLocale::Gusii175聽
QLocale::Haitian222聽
QLocale::Hanunoo280Since Qt 5.1
QLocale::Hausa47聽
QLocale::Hawaiian163聽
QLocale::Hebrew48聽
QLocale::Herero223聽
QLocale::HieroglyphicLuwian344Since Qt 5.7
QLocale::Hindi49聽
QLocale::HiriMotu224聽
QLocale::HmongNjua333Since Qt 5.5
QLocale::Ho334Since Qt 5.5
QLocale::Hungarian50聽
QLocale::Icelandic51聽
QLocale::Ido360Since Qt 5.12
QLocale::Igbo149聽
QLocale::InariSami326Since Qt 5.5
QLocale::Indonesian52聽
QLocale::Ingush281Since Qt 5.1
QLocale::Interlingua53聽
QLocale::Interlingue54聽
QLocale::Inuktitut55聽
QLocale::Inupiak56聽
QLocale::Irish57聽
QLocale::Italian58聽
QLocale::Japanese59聽
QLocale::Javanese60聽
QLocale::Jju158聽
QLocale::JolaFonyi241聽
QLocale::Kabuverdianu196聽
QLocale::Kabyle184聽
QLocale::Kako258聽
QLocale::Kalenjin198聽
QLocale::Kamba150聽
QLocale::Kannada61聽
QLocale::Kanuri225聽
QLocale::Kashmiri62聽
QLocale::Kazakh63聽
QLocale::Kenyang319Since Qt 5.5
QLocale::Khmer23聽
QLocale::Kiche323Since Qt 5.5
QLocale::Kikuyu178聽
QLocale::Kinyarwanda64聽
QLocale::Kirghiz65聽
QLocale::Komi226聽
QLocale::Kongo227聽
QLocale::Konkani147聽
QLocale::Korean66聽
QLocale::Koro154聽
QLocale::KoyraboroSenni213聽
QLocale::KoyraChiini208聽
QLocale::Kpelle169聽
QLocale::Kurdish67聽
QLocale::KurundiRundiObsolete, please use Rundi
QLocale::Kwanyama228聽
QLocale::Kwasio246聽
QLocale::Lakota313Since Qt 5.3
QLocale::Langi193聽
QLocale::Lao69聽
QLocale::LargeFloweryMiao282Since Qt 5.1
QLocale::Latin70聽
QLocale::Latvian71聽
QLocale::Lepcha283Since Qt 5.1
QLocale::Lezghian335Since Qt 5.5
QLocale::Limburgish229聽
QLocale::Limbu284Since Qt 5.1
QLocale::LinearA332Since Qt 5.5
QLocale::Lingala72聽
QLocale::Lisu285Since Qt 5.1
QLocale::LiteraryChinese345Since Qt 5.7
QLocale::Lithuanian73聽
QLocale::Lojban361Since Qt 5.12
QLocale::LowerSorbian317Since Qt 5.5
QLocale::LowGerman170聽
QLocale::LubaKatanga230聽
QLocale::LuleSami325Since Qt 5.5
QLocale::Luo210聽
QLocale::Lu286Since Qt 5.1
QLocale::Luxembourgish231聽
QLocale::Luyia204聽
QLocale::Lycian287Since Qt 5.1
QLocale::Lydian288Since Qt 5.1
QLocale::Macedonian74聽
QLocale::Machame200聽
QLocale::Maithili339Since Qt 5.5
QLocale::MakhuwaMeetto244聽
QLocale::Makonde192聽
QLocale::Malagasy75聽
QLocale::Malay76聽
QLocale::Malayalam77聽
QLocale::Maltese78聽
QLocale::Mandingo289Since Qt 5.1
QLocale::ManichaeanMiddlePersian329Since Qt 5.5
QLocale::Manipuri290Since Qt 5.1
QLocale::Manx144聽
QLocale::Maori79聽
QLocale::Mapuche315Since Qt 5.5
QLocale::Marathi80聽
QLocale::Marshallese81聽
QLocale::Masai202聽
QLocale::Mazanderani346Since Qt 5.7
QLocale::Mende330Since Qt 5.5
QLocale::Meroitic291Since Qt 5.1
QLocale::Meru197聽
QLocale::Meta259聽
QLocale::Mohawk320Since Qt 5.5
QLocale::MoldavianRomanianObsolete, please use Romanian
QLocale::Mongolian82聽
QLocale::Mono337Since Qt 5.5
QLocale::Morisyen191聽
QLocale::Mru347Since Qt 5.7
QLocale::Mundang245聽
QLocale::Muscogee368Since Qt 5.14
QLocale::Nama199聽
QLocale::NauruLanguage83聽
QLocale::Navaho232聽
QLocale::Ndonga233聽
QLocale::Nepali84聽
QLocale::Newari348Since Qt 5.7
QLocale::Ngiemboon260聽
QLocale::Ngomba257聽
QLocale::Nko321Since Qt 5.5
QLocale::NorthernLuri349Since Qt 5.7
QLocale::NorthernSami173聽
QLocale::NorthernSotho172聽
QLocale::NorthernThai292Since Qt 5.1
QLocale::NorthNdebele181聽
QLocale::NorwegianBokmal85same as Norwegian
QLocale::NorwegianNynorsk141聽
QLocale::NorwegianNorwegianBokmalsame as NorwegianBokmal
QLocale::Nuer247聽
QLocale::Nyanja165聽
QLocale::Nyankole185聽
QLocale::Occitan86聽
QLocale::Ojibwa234聽
QLocale::OldIrish293Since Qt 5.1
QLocale::OldNorse294Since Qt 5.1
QLocale::OldPersian295Since Qt 5.1
QLocale::OldTurkish296Since Qt 5.1
QLocale::Oriya87聽
QLocale::Oromo3聽
QLocale::Osage358Since Qt 5.7
QLocale::Ossetic101聽
QLocale::Pahlavi297Since Qt 5.1
QLocale::Palauan350Since Qt 5.7
QLocale::Pali235聽
QLocale::Papiamento351Since Qt 5.7
QLocale::Parthian298Since Qt 5.1
QLocale::Pashto88聽
QLocale::Persian89聽
QLocale::Phoenician299Since Qt 5.1
QLocale::Polish90聽
QLocale::Portuguese91聽
QLocale::PrakritLanguage300Since Qt 5.1
QLocale::Prussian322Since Qt 5.5
QLocale::Punjabi92聽
QLocale::Quechua93聽
QLocale::Rejang301Since Qt 5.1
QLocale::RhaetoRomanceRomanshObsolete, please use Romansh
QLocale::Romanian95聽
QLocale::Romansh94聽
QLocale::Rombo182聽
QLocale::Rundi68聽
QLocale::Russian96聽
QLocale::Rwa209聽
QLocale::Sabaean302Since Qt 5.1
QLocale::Saho207聽
QLocale::Sakha248聽
QLocale::Samaritan303Since Qt 5.1
QLocale::Samburu179聽
QLocale::Samoan97聽
QLocale::Sango98聽
QLocale::Sangu249聽
QLocale::Sanskrit99聽
QLocale::Santali304Since Qt 5.1
QLocale::Saraiki352Since Qt 5.7
QLocale::Sardinian115聽
QLocale::Saurashtra305Since Qt 5.1
QLocale::Sena180聽
QLocale::Serbian100聽
QLocale::SerboCroatianSerbianObsolete, please use Serbian
QLocale::Shambala214聽
QLocale::Shona104聽
QLocale::SichuanYi168聽
QLocale::Sicilian362Since Qt 5.12
QLocale::Sidamo155聽
QLocale::Silesian369Since Qt 5.14
QLocale::Sindhi105聽
QLocale::Sinhala106聽
QLocale::SkoltSami327Since Qt 5.5
QLocale::Slovak108聽
QLocale::Slovenian109聽
QLocale::Soga203聽
QLocale::Somali110聽
QLocale::Sora306Since Qt 5.1
QLocale::SouthernKurdish363Since Qt 5.12
QLocale::SouthernSami324Since Qt 5.5
QLocale::SouthernSotho102聽
QLocale::SouthNdebele171聽
QLocale::Spanish111聽
QLocale::StandardMoroccanTamazight314Since Qt 5.3
QLocale::Sundanese112聽
QLocale::Swahili113聽
QLocale::Swati107聽
QLocale::Swedish114聽
QLocale::SwissGerman167聽
QLocale::Sylheti307Since Qt 5.1
QLocale::Syriac151聽
QLocale::Tachelhit183聽
QLocale::TagalogFilipinoObsolete, please use Filipino
QLocale::Tagbanwa308Since Qt 5.1
QLocale::Tahitian127聽
QLocale::TaiDam309Since Qt 5.1
QLocale::TaiNua310Since Qt 5.1
QLocale::Taita176聽
QLocale::Tajik116聽
QLocale::Tamil117聽
QLocale::Tangut359Since Qt 5.7
QLocale::Taroko174聽
QLocale::Tasawaq251聽
QLocale::Tatar118聽
QLocale::TedimChin338Since Qt 5.5
QLocale::Telugu119聽
QLocale::Teso206聽
QLocale::Thai120聽
QLocale::Tibetan121聽
QLocale::Tigre157聽
QLocale::Tigrinya122聽
QLocale::TokelauLanguage353Since Qt 5.7
QLocale::TokPisin354Since Qt 5.7
QLocale::Tongan123聽
QLocale::Tsonga124聽
QLocale::Tswana103聽
QLocale::Turkish125聽
QLocale::Turkmen126聽
QLocale::TuvaluLanguage355Since Qt 5.7
QLocale::TwiAkanObsolete, please use Akan
QLocale::Tyap164聽
QLocale::Ugaritic311Since Qt 5.1
QLocale::Uighur128聽
QLocale::UigurUighurObsolete, please use Uighur
QLocale::Ukrainian129聽
QLocale::UncodedLanguages356Since Qt 5.7
QLocale::UpperSorbian318Since Qt 5.5
QLocale::Urdu130聽
QLocale::Uzbek131聽
QLocale::Vai252聽
QLocale::Venda160聽
QLocale::Vietnamese132聽
QLocale::Volapuk133聽
QLocale::Vunjo187聽
QLocale::Walamo162聽
QLocale::Walloon236聽
QLocale::Walser253聽
QLocale::Warlpiri328Since Qt 5.5
QLocale::Welsh134聽
QLocale::WesternBalochi364Since Qt 5.12
QLocale::WesternFrisian38same as Frisian
QLocale::Wolof135聽
QLocale::Xhosa136聽
QLocale::Yangben254聽
QLocale::Yiddish137聽
QLocale::Yoruba138聽
QLocale::Zarma239聽
QLocale::Zhuang139聽
QLocale::Zulu140聽

See also language() and languageToString().

enum QLocale::MeasurementSystem

This enum defines which units are used for measurement.

ConstantValueDescription
QLocale::MetricSystem0This value indicates metric units, such as meters, centimeters and millimeters.
QLocale::ImperialUSSystem1This value indicates imperial units, such as inches and miles as they are used in the United States.
QLocale::ImperialUKSystem2This value indicates imperial units, such as inches and miles as they are used in the United Kingdom.
QLocale::ImperialSystemImperialUSSystemProvided for compatibility. Same as ImperialUSSystem

This enum was introduced or modified in Qt 4.4.

enum QLocale::NumberOption
flags QLocale::NumberOptions

This enum defines a set of options for number-to-string and string-to-number conversions. They can be retrieved with numberOptions() and set with setNumberOptions().

ConstantValueDescription
QLocale::DefaultNumberOptions0x0This option represents the default behavior, with group separators, with one leading zero in single digit exponents, and without trailing zeroes after the decimal dot.
QLocale::OmitGroupSeparator0x01If this option is set, the number-to-string functions will not insert group separators in their return values. The default is to insert group separators.
QLocale::RejectGroupSeparator0x02If this option is set, the string-to-number functions will fail if they encounter group separators in their input. The default is to accept numbers containing correctly placed group separators.
QLocale::OmitLeadingZeroInExponent0x04If this option is set, the number-to-string functions will not pad exponents with zeroes when printing floating point numbers in scientific notation. The default is to add one leading zero to single digit exponents.
QLocale::RejectLeadingZeroInExponent0x08If this option is set, the string-to-number functions will fail if they encounter an exponent padded with zeroes when parsing a floating point number in scientific notation. The default is to accept such padding.
QLocale::IncludeTrailingZeroesAfterDot0x10If this option is set, the number-to-string functions will pad numbers with zeroes to the requested precision in "g" or "most concise" mode, even if the number of significant digits is lower than the requested precision. The default is to omit trailing zeroes.
QLocale::RejectTrailingZeroesAfterDot0x20If this option is set, the string-to-number functions will fail if they encounter trailing zeroes after the decimal dot when parsing a number in scientific or decimal representation. The default is to accept trailing zeroes.

The NumberOptions type is a typedef for QFlags<NumberOption>. It stores an OR combination of NumberOption values.

See also setNumberOptions() and numberOptions().

enum QLocale::QuotationStyle

This enum defines a set of possible styles for locale specific quotation.

ConstantValueDescription
QLocale::StandardQuotation0If this option is set, the standard quotation marks will be used to quote strings.
QLocale::AlternateQuotation1If this option is set, the alternate quotation marks will be used to quote strings.

This enum was introduced or modified in Qt 4.8.

See also quoteString().

enum QLocale::Script

This enumerated type is used to specify a script.

ConstantValueDescription
QLocale::AnyScript0聽
QLocale::AdlamScript134Since Qt 5.7
QLocale::AhomScript128Since Qt 5.7
QLocale::AnatolianHieroglyphsScript129Since Qt 5.7
QLocale::ArabicScript1聽
QLocale::ArmenianScript10聽
QLocale::AvestanScript36Since Qt 5.1
QLocale::BalineseScript37Since Qt 5.1
QLocale::BamumScript38Since Qt 5.1
QLocale::BassaVahScript106Since Qt 5.5
QLocale::BatakScript39Since Qt 5.1
QLocale::BengaliScript11聽
QLocale::BhaiksukiScript135Since Qt 5.7
QLocale::BopomofoScript40Since Qt 5.1
QLocale::BrahmiScript41Since Qt 5.1
QLocale::BrailleScript103Since Qt 5.1
QLocale::BugineseScript42Since Qt 5.1
QLocale::BuhidScript43Since Qt 5.1
QLocale::CanadianAboriginalScript44Since Qt 5.1
QLocale::CarianScript45Since Qt 5.1
QLocale::CaucasianAlbanianScript105Since Qt 5.5
QLocale::ChakmaScript46Since Qt 5.1
QLocale::ChamScript47Since Qt 5.1
QLocale::CherokeeScript12聽
QLocale::CopticScript48Since Qt 5.1
QLocale::CuneiformScript94Since Qt 5.1
QLocale::CypriotScript49Since Qt 5.1
QLocale::CyrillicScript2聽
QLocale::DeseretScript3Since Qt 5.1
QLocale::DevanagariScript13聽
QLocale::DuployanScript107Since Qt 5.5
QLocale::EgyptianHieroglyphsScript50Since Qt 5.1
QLocale::ElbasanScript108Since Qt 5.5
QLocale::EthiopicScript14聽
QLocale::FraserScript51Since Qt 5.1
QLocale::GeorgianScript15聽
QLocale::GlagoliticScript52Since Qt 5.1
QLocale::GothicScript53Since Qt 5.1
QLocale::GranthaScript109Since Qt 5.5
QLocale::GreekScript16聽
QLocale::GujaratiScript17聽
QLocale::GurmukhiScript4聽
QLocale::HangulScript55Since Qt 5.1
QLocale::HanScript54Since Qt 5.1
QLocale::HanunooScript56Since Qt 5.1
QLocale::HanWithBopomofoScript140Since Qt 5.7
QLocale::HatranScript130Since Qt 5.7
QLocale::HebrewScript18聽
QLocale::HiraganaScript104Since Qt 5.1
QLocale::ImperialAramaicScript57Since Qt 5.1
QLocale::InscriptionalPahlaviScript58Since Qt 5.1
QLocale::InscriptionalParthianScript59Since Qt 5.1
QLocale::JamoScript141Since Qt 5.7
QLocale::JapaneseScript19聽
QLocale::JavaneseScript60Since Qt 5.1
QLocale::KaithiScript61Since Qt 5.1
QLocale::KannadaScript21聽
QLocale::KatakanaScript62Since Qt 5.1
QLocale::KayahLiScript63Since Qt 5.1
QLocale::KharoshthiScript64Since Qt 5.1
QLocale::KhmerScript20Since Qt 5.1
QLocale::KhojkiScript111Since Qt 5.5
QLocale::KhudawadiScript125Since Qt 5.5
QLocale::KoreanScript22聽
QLocale::LannaScript65Since Qt 5.1
QLocale::LaoScript23聽
QLocale::LatinScript7聽
QLocale::LepchaScript66Since Qt 5.1
QLocale::LimbuScript67Since Qt 5.1
QLocale::LinearAScript112Since Qt 5.5
QLocale::LinearBScript68Since Qt 5.1
QLocale::LycianScript69Since Qt 5.1
QLocale::LydianScript70Since Qt 5.1
QLocale::MahajaniScript113Since Qt 5.5
QLocale::MalayalamScript24聽
QLocale::MandaeanScript71Since Qt 5.1
QLocale::ManichaeanScript114Since Qt 5.5
QLocale::MarchenScript136Since Qt 5.7
QLocale::MeiteiMayekScript72Since Qt 5.1
QLocale::MendeKikakuiScript115Since Qt 5.5
QLocale::MeroiticCursiveScript74Since Qt 5.1
QLocale::MeroiticScript73Since Qt 5.1
QLocale::ModiScript116Since Qt 5.5
QLocale::MongolianScript8聽
QLocale::MroScript117Since Qt 5.5
QLocale::MultaniScript131Since Qt 5.7
QLocale::MyanmarScript25聽
QLocale::NabataeanScript119Since Qt 5.5
QLocale::NewaScript137Since Qt 5.7
QLocale::NewTaiLueScript76Since Qt 5.1
QLocale::NkoScript75Since Qt 5.1
QLocale::OghamScript77Since Qt 5.1
QLocale::OlChikiScript78Since Qt 5.1
QLocale::OldHungarianScript132Since Qt 5.7
QLocale::OldItalicScript79Since Qt 5.1
QLocale::OldNorthArabianScript118Since Qt 5.5
QLocale::OldPermicScript122Since Qt 5.5
QLocale::OldPersianScript80Since Qt 5.1
QLocale::OldSouthArabianScript81Since Qt 5.1
QLocale::OriyaScript26聽
QLocale::OrkhonScript82Since Qt 5.1
QLocale::OsageScript138Since Qt 5.7
QLocale::OsmanyaScript83Since Qt 5.1
QLocale::PahawhHmongScript110Since Qt 5.5
QLocale::PalmyreneScript120Since Qt 5.5
QLocale::PauCinHauScript121Since Qt 5.5
QLocale::PhagsPaScript84Since Qt 5.1
QLocale::PhoenicianScript85Since Qt 5.1
QLocale::PollardPhoneticScript86Since Qt 5.1
QLocale::PsalterPahlaviScript123Since Qt 5.5
QLocale::RejangScript87Since Qt 5.1
QLocale::RunicScript88Since Qt 5.1
QLocale::SamaritanScript89Since Qt 5.1
QLocale::SaurashtraScript90Since Qt 5.1
QLocale::SharadaScript91Since Qt 5.1
QLocale::ShavianScript92Since Qt 5.1
QLocale::SiddhamScript124Since Qt 5.5
QLocale::SignWritingScript133Since Qt 5.7
QLocale::SimplifiedChineseScriptSimplifiedHanScriptsame as SimplifiedHanScript
QLocale::SimplifiedHanScript5same as SimplifiedChineseScript
QLocale::SinhalaScript32聽
QLocale::SoraSompengScript93Since Qt 5.1
QLocale::SundaneseScript95Since Qt 5.1
QLocale::SylotiNagriScript96Since Qt 5.1
QLocale::SyriacScript33聽
QLocale::TagalogScript97Since Qt 5.1
QLocale::TagbanwaScript98Since Qt 5.1
QLocale::TaiLeScript99Since Qt 5.1
QLocale::TaiVietScript100Since Qt 5.1
QLocale::TakriScript101Since Qt 5.1
QLocale::TamilScript27聽
QLocale::TangutScript139Since Qt 5.7
QLocale::TeluguScript28聽
QLocale::ThaanaScript29聽
QLocale::ThaiScript30聽
QLocale::TibetanScript31聽
QLocale::TifinaghScript9聽
QLocale::TirhutaScript126Since Qt 5.5
QLocale::TraditionalChineseScriptTraditionalHanScriptsame as TraditionalHanScript
QLocale::TraditionalHanScript6same as TraditionalChineseScript
QLocale::UgariticScript102Since Qt 5.1
QLocale::VaiScript35聽
QLocale::VarangKshitiScript127Since Qt 5.5
QLocale::YiScript34聽

See also script(), scriptToString(), and languageToString().

Member Function Documentation

QString QLocale::toCurrencyString(float value, const QString &symbol = QString()) const

QString QLocale::toCurrencyString(float i, const QString &symbol, int precision) const

This function overloads toCurrencyString().

QLocale::QLocale(const QLocale &other)

Constructs a QLocale object as a copy of other.

QLocale::QLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)

Constructs a QLocale object with the specified language, script and country.

  • If the language/script/country is found in the database, it is used.
  • If both script is AnyScript and country is AnyCountry, the language is used with the most appropriate available script and country (for example, Germany for German),
  • If either script is AnyScript or country is AnyCountry, the language is used with the first locale that matches the given script and country.
  • If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).

The language, script and country that are actually used can be queried using language(), script() and country().

This function was introduced in Qt 4.8.

See also setDefault(), language(), script(), and country().

QLocale::QLocale(QLocale::Language language, QLocale::Country country = AnyCountry)

Constructs a QLocale object with the specified language and country.

  • If the language/country pair is found in the database, it is used.
  • If the language is found but the country is not, or if the country is AnyCountry, the language is used with the most appropriate available country (for example, Germany for German),
  • If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).

The language and country that are actually used can be queried using language() and country().

See also setDefault(), language(), and country().

QLocale::QLocale(const QString &name)

Constructs a QLocale object with the specified name, which has the format "language[_script][_country][.codeset][@modifier]" or "C", where:

  • language is a lowercase, two-letter, ISO 639 language code (also some three-letter codes),
  • script is a titlecase, four-letter, ISO 15924 script code,
  • country is an uppercase, two-letter, ISO 3166 country code (also "419" as defined by United Nations),
  • and codeset and modifier are ignored.

The separator can be either underscore or a minus sign.

If the string violates the locale format, or language is not a valid ISO 639 code, the "C" locale is used instead. If country is not present, or is not a valid ISO 3166 code, the most appropriate country is chosen for the specified language.

The language, script and country codes are converted to their respective Language, Script and Country enums. After this conversion is performed, the constructor behaves exactly like QLocale(Country, Script, Language).

This constructor is much slower than QLocale(Country, Script, Language).

See also bcp47Name().

QLocale::QLocale()

Constructs a QLocale object initialized with the default locale. If no default locale was set using setDefault(), this locale will be the same as the one returned by system().

See also setDefault().

QLocale &QLocale::operator=(const QLocale &other)

Assigns other to this QLocale object and returns a reference to this QLocale object.

QLocale::~QLocale()

Destructor

QString QLocale::amText() const

Returns the localized name of the "AM" suffix for times specified using the conventions of the 12-hour clock.

This function was introduced in Qt 4.5.

See also pmText().

QString QLocale::bcp47Name() const

Returns the dash-separated language, script and country (and possibly other BCP47 fields) of this locale as a string.

Unlike the uiLanguages() the returned value of the bcp47Name() represents the locale name of the QLocale data but not the language the user-interface should be in.

This function tries to conform the locale name to BCP47.

This function was introduced in Qt 4.8.

See also language(), country(), script(), and uiLanguages().

[static] QLocale QLocale::c()

Returns a QLocale object initialized to the "C" locale.

This locale is based on en_US but with various quirks of its own, such as simplified number formatting and its own date formatting. It implements the POSIX standards that describe the behavior of standard library functions of the "C" programming language.

Among other things, this means its collation order is based on the ASCII values of letters, so that (for case-sensitive sorting) all upper-case letters sort before any lower-case one (rather than each letter's upper- and lower-case forms sorting adjacent to one another, before the next letter's two forms).

See also system().

QLocale QLocale::collation() const

Returns the locale to use for collation.

The result is usually this locale; however, the system locale (which is commonly the default locale) will return the system collation locale. The result is suitable for passing to QCollator's constructor.

This function was introduced in Qt 5.13.

See also QCollator.

QLocale::Country QLocale::country() const

Returns the country of this locale.

See also language(), script(), countryToString(), and bcp47Name().

[static] QString QLocale::countryToString(QLocale::Country country)

Returns a QString containing the name of country.

See also languageToString(), scriptToString(), country(), and bcp47Name().

QString QLocale::createSeparatedList(const QStringList &list) const

Returns a string that represents a join of a given list of strings with a separator defined by the locale.

This function was introduced in Qt 4.8.

QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format = CurrencySymbol) const

Returns a currency symbol according to the format.

This function was introduced in Qt 4.8.

QString QLocale::dateFormat(QLocale::FormatType format = LongFormat) const

Returns the date format used for the current locale.

If format is LongFormat the format will be a long version. Otherwise it uses a shorter version.

This function was introduced in Qt 4.1.

See also QDate::toString() and QDate::fromString().

QString QLocale::dateTimeFormat(QLocale::FormatType format = LongFormat) const

Returns the date time format used for the current locale.

If format is ShortFormat the format will be a short version. Otherwise it uses a longer version.

This function was introduced in Qt 4.4.

See also QDateTime::toString() and QDateTime::fromString().

QString QLocale::dayName(int day, QLocale::FormatType type = LongFormat) const

Returns the localized name of the day (where 1 represents Monday, 2 represents Tuesday and so on), in the format specified by type.

This function was introduced in Qt 4.2.

See also monthName() and standaloneDayName().

QChar QLocale::decimalPoint() const

Returns the decimal point character of this locale.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.1.

See also groupSeparator() and toString().

QChar QLocale::exponential() const

Returns the exponential character of this locale, used to separate exponent from mantissa in some floating-point numeric representations.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.1.

See also toString(double, char, int).

Qt::DayOfWeek QLocale::firstDayOfWeek() const

Returns the first day of the week according to the current locale.

This function was introduced in Qt 4.8.

QString QLocale::formattedDataSize(qint64 bytes, int precision = 2, QLocale::DataSizeFormats format = DataSizeIecFormat) const

Converts a size in bytes to a human-readable localized string, comprising a number and a quantified unit. The quantifier is chosen such that the number is at least one, and as small as possible. For example if bytes is 16384, precision is 2, and format is DataSizeIecFormat (the default), this function returns "16.00 KiB"; for 1330409069609 bytes it returns "1.21 GiB"; and so on. If format is DataSizeIecFormat or DataSizeTraditionalFormat, the given number of bytes is divided by a power of 1024, with result less than 1024; for DataSizeSIFormat, it is divided by a power of 1000, with result less than 1000. DataSizeIecFormat uses the new IEC standard quantifiers Ki, Mi and so on, whereas DataSizeSIFormat uses the older SI quantifiers k, M, etc., and DataSizeTraditionalFormat abuses them.

This function was introduced in Qt 5.10.

QChar QLocale::groupSeparator() const

Returns the group separator character of this locale.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.1.

See also decimalPoint() and toString().

QLocale::Language QLocale::language() const

Returns the language of this locale.

See also script(), country(), languageToString(), and bcp47Name().

[static] QString QLocale::languageToString(QLocale::Language language)

Returns a QString containing the name of language.

See also countryToString(), scriptToString(), and bcp47Name().

[static] QList<QLocale> QLocale::matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country)

Returns a list of valid locale objects that match the given language, script and country.

Getting a list of all locales: QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);

Getting a list of locales suitable for Russia: QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::Russia);

This function was introduced in Qt 4.8.

QLocale::MeasurementSystem QLocale::measurementSystem() const

Returns the measurement system for the locale.

This function was introduced in Qt 4.4.

QString QLocale::monthName(int month, QLocale::FormatType type = LongFormat) const

Returns the localized name of month, in the format specified by type.

This function was introduced in Qt 4.2.

See also dayName() and standaloneMonthName().

QString QLocale::name() const

Returns the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.

Note that even if QLocale object was constructed with an explicit script, name() will not contain it for compatibility reasons. Use bcp47Name() instead if you need a full locale name.

See also QLocale(), language(), script(), country(), and bcp47Name().

QString QLocale::nativeCountryName() const

Returns a native name of the country for the locale. For example "Espa帽a" for Spanish/Spain locale.

This function was introduced in Qt 4.8.

See also nativeLanguageName() and countryToString().

QString QLocale::nativeLanguageName() const

Returns a native name of the language for the locale. For example "Schwiizert眉眉tsch" for Swiss-German locale.

This function was introduced in Qt 4.8.

See also nativeCountryName() and languageToString().

QChar QLocale::negativeSign() const

Returns the negative sign character of this locale.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.1.

See also positiveSign() and toString().

QLocale::NumberOptions QLocale::numberOptions() const

Returns the options related to number conversions for this QLocale instance.

By default, no options are set for the standard locales, except for the "C" locale, which has OmitGroupSeparator set by default.

This function was introduced in Qt 4.2.

See also setNumberOptions(), toString(), and groupSeparator().

QChar QLocale::percent() const

Returns the percent character of this locale.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.1.

See also toString().

QString QLocale::pmText() const

Returns the localized name of the "PM" suffix for times specified using the conventions of the 12-hour clock.

This function was introduced in Qt 4.5.

See also amText().

QChar QLocale::positiveSign() const

Returns the positive sign character of this locale.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.5.

See also negativeSign() and toString().

QString QLocale::quoteString(const QString &str, QLocale::QuotationStyle style = StandardQuotation) const

Returns str quoted according to the current locale using the given quotation style.

This function was introduced in Qt 4.8.

QString QLocale::quoteString(const QStringRef &str, QLocale::QuotationStyle style = StandardQuotation) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QLocale::Script QLocale::script() const

Returns the script of this locale.

This function was introduced in Qt 4.8.

See also language(), country(), languageToString(), scriptToString(), and bcp47Name().

[static] QString QLocale::scriptToString(QLocale::Script script)

Returns a QString containing the name of script.

This function was introduced in Qt 4.8.

See also languageToString(), countryToString(), script(), and bcp47Name().

[static] void QLocale::setDefault(const QLocale &locale)

Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.

Warning: In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created.

Warning: This function is not reentrant.

See also system() and c().

void QLocale::setNumberOptions(QLocale::NumberOptions options)

Sets the options related to number conversions for this QLocale instance.

This function was introduced in Qt 4.2.

See also numberOptions().

QString QLocale::standaloneDayName(int day, QLocale::FormatType type = LongFormat) const

Returns the localized name of the day (where 1 represents Monday, 2 represents Tuesday and so on) that is used as a standalone text, in the format specified by type.

If the locale information does not specify the standalone day name then return value is the same as in dayName().

This function was introduced in Qt 4.5.

See also dayName() and standaloneMonthName().

QString QLocale::standaloneMonthName(int month, QLocale::FormatType type = LongFormat) const

Returns the localized name of month that is used as a standalone text, in the format specified by type.

If the locale information doesn't specify the standalone month name then return value is the same as in monthName().

This function was introduced in Qt 4.5.

See also monthName() and standaloneDayName().

void QLocale::swap(QLocale &other)

Swaps locale other with this locale. This operation is very fast and never fails.

This function was introduced in Qt 5.6.

[static] QLocale QLocale::system()

Returns a QLocale object initialized to the system locale.

On Windows and Mac, this locale will use the decimal/grouping characters and date/time formats specified in the system configuration panel.

See also c().

Qt::LayoutDirection QLocale::textDirection() const

Returns the text direction of the language.

This function was introduced in Qt 4.7.

QString QLocale::timeFormat(QLocale::FormatType format = LongFormat) const

Returns the time format used for the current locale.

If format is LongFormat the format will be a long version. Otherwise it uses a shorter version.

This function was introduced in Qt 4.1.

See also QTime::toString() and QTime::fromString().

QString QLocale::toCurrencyString(qlonglong value, const QString &symbol = QString()) const

Returns a localized string representation of value as a currency. If the symbol is provided it is used instead of the default currency symbol.

This function was introduced in Qt 4.8.

See also currencySymbol().

QString QLocale::toCurrencyString(qulonglong value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QString QLocale::toCurrencyString(short value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QString QLocale::toCurrencyString(ushort value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QString QLocale::toCurrencyString(int value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QString QLocale::toCurrencyString(uint value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QString QLocale::toCurrencyString(double value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

QString QLocale::toCurrencyString(double value, const QString &symbol, int precision) const

This function overloads toCurrencyString().

Returns a localized string representation of value as a currency. If the symbol is provided it is used instead of the default currency symbol. If the precision is provided it is used to set the precision of the currency value.

This function was introduced in Qt 5.7.

See also currencySymbol().

QDate QLocale::toDate(const QString &string, QLocale::FormatType format = LongFormat) const

Parses the date string given in string and returns the date. The format of the date string is chosen according to the format parameter (see dateFormat()).

If the date could not be parsed, returns an invalid date.

This function was introduced in Qt 4.4.

See also dateFormat(), toTime(), toDateTime(), and QDate::fromString().

QDate QLocale::toDate(const QString &string, const QString &format) const

Parses the date string given in string and returns the date. See QDate::fromString() for information on the expressions that can be used with this function.

This function searches month names and the names of the days of the week in the current locale.

If the date could not be parsed, returns an invalid date.

This function was introduced in Qt 4.4.

See also dateFormat(), toTime(), toDateTime(), and QDate::fromString().

QDate QLocale::toDate(const QString &string, QLocale::FormatType format, QCalendar cal) const

This is an overloaded function.

This function was introduced in Qt 5.14.

QDate QLocale::toDate(const QString &string, const QString &format, QCalendar cal) const

This is an overloaded function.

This function was introduced in Qt 5.14.

QDateTime QLocale::toDateTime(const QString &string, QLocale::FormatType format = LongFormat) const

Parses the date/time string given in string and returns the time. The format of the date/time string is chosen according to the format parameter (see dateTimeFormat()).

If the string could not be parsed, returns an invalid QDateTime.

This function was introduced in Qt 4.4.

See also dateTimeFormat(), toTime(), toDate(), and QDateTime::fromString().

QDateTime QLocale::toDateTime(const QString &string, const QString &format) const

Parses the date/time string given in string and returns the time. See QDateTime::fromString() for information on the expressions that can be used with this function.

Note: The month and day names used must be given in the user's local language.

If the string could not be parsed, returns an invalid QDateTime.

This function was introduced in Qt 4.4.

See also dateTimeFormat(), toTime(), toDate(), and QDateTime::fromString().

QDateTime QLocale::toDateTime(const QString &string, QLocale::FormatType format, QCalendar cal) const

This is an overloaded function.

This function was introduced in Qt 5.14.

QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCalendar cal) const

This is an overloaded function.

This function was introduced in Qt 5.14.

double QLocale::toDouble(const QString &s, bool *ok = nullptr) const

Returns the double represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

bool ok;
double d;

QLocale c(QLocale::C);
d = c.toDouble( "1234.56", &ok );  // ok == true, d == 1234.56
d = c.toDouble( "1,234.56", &ok ); // ok == true, d == 1234.56
d = c.toDouble( "1234,56", &ok );  // ok == false

QLocale german(QLocale::German);
d = german.toDouble( "1234,56", &ok );  // ok == true, d == 1234.56
d = german.toDouble( "1.234,56", &ok ); // ok == true, d == 1234.56
d = german.toDouble( "1234.56", &ok );  // ok == false

d = german.toDouble( "1.234", &ok );    // ok == true, d == 1234.0

Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.

This function ignores leading and trailing whitespace.

See also toFloat(), toInt(), and toString().

double QLocale::toDouble(const QStringRef &s, bool *ok = nullptr) const

Returns the double represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

bool ok;
double d;

QLocale c(QLocale::C);
d = c.toDouble( "1234.56", &ok );  // ok == true, d == 1234.56
d = c.toDouble( "1,234.56", &ok ); // ok == true, d == 1234.56
d = c.toDouble( "1234,56", &ok );  // ok == false

QLocale german(QLocale::German);
d = german.toDouble( "1234,56", &ok );  // ok == true, d == 1234.56
d = german.toDouble( "1.234,56", &ok ); // ok == true, d == 1234.56
d = german.toDouble( "1234.56", &ok );  // ok == false

d = german.toDouble( "1.234", &ok );    // ok == true, d == 1234.0

Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toFloat(), toInt(), and toString().

double QLocale::toDouble(QStringView s, bool *ok = nullptr) const

Returns the double represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

Unlike QString::toDouble(), this function does not fall back to the "C" locale if the string cannot be interpreted in this locale.

bool ok;
double d;

QLocale c(QLocale::C);
d = c.toDouble(u"1234.56", &ok);  // ok == true, d == 1234.56
d = c.toDouble(u"1,234.56", &ok); // ok == true, d == 1234.56
d = c.toDouble(u"1234,56", &ok);  // ok == false

QLocale german(QLocale::German);
d = german.toDouble(u"1234,56", &ok);  // ok == true, d == 1234.56
d = german.toDouble(u"1.234,56", &ok); // ok == true, d == 1234.56
d = german.toDouble(u"1234.56", &ok);  // ok == false

d = german.toDouble(u"1.234", &ok);    // ok == true, d == 1234.0

Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toFloat(), toInt(), and toString().

float QLocale::toFloat(const QString &s, bool *ok = nullptr) const

Returns the float represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

This function ignores leading and trailing whitespace.

See also toDouble(), toInt(), and toString().

float QLocale::toFloat(const QStringRef &s, bool *ok = nullptr) const

Returns the float represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toDouble(), toInt(), and toString().

float QLocale::toFloat(QStringView s, bool *ok = nullptr) const

Returns the float represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toDouble(), toInt(), and toString().

int QLocale::toInt(const QString &s, bool *ok = nullptr) const

Returns the int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See also toUInt() and toString().

int QLocale::toInt(const QStringRef &s, bool *ok = nullptr) const

Returns the int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toUInt() and toString().

int QLocale::toInt(QStringView s, bool *ok = nullptr) const

Returns the int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toUInt() and toString().

long QLocale::toLong(const QString &s, bool *ok = nullptr) const

Returns the long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.13.

See also toInt(), toULong(), toDouble(), and toString().

long QLocale::toLong(const QStringRef &s, bool *ok = nullptr) const

Returns the long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.13.

See also toInt(), toULong(), toDouble(), and toString().

long QLocale::toLong(QStringView s, bool *ok = nullptr) const

Returns the long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.13.

See also toInt(), toULong(), toDouble(), and toString().

qlonglong QLocale::toLongLong(const QString &s, bool *ok = nullptr) const

Returns the long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See also toInt(), toULongLong(), toDouble(), and toString().

qlonglong QLocale::toLongLong(const QStringRef &s, bool *ok = nullptr) const

Returns the long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toInt(), toULongLong(), toDouble(), and toString().

qlonglong QLocale::toLongLong(QStringView s, bool *ok = nullptr) const

Returns the long long int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toInt(), toULongLong(), toDouble(), and toString().

QString QLocale::toLower(const QString &str) const

Returns a lowercase copy of str.

If Qt Core is using the ICU libraries, they will be used to perform the transformation according to the rules of the current locale. Otherwise the conversion may be done in a platform-dependent manner, with QString::toLower() as a generic fallback.

This function was introduced in Qt 4.8.

See also QString::toLower().

short QLocale::toShort(const QString &s, bool *ok = nullptr) const

Returns the short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See also toUShort() and toString().

short QLocale::toShort(const QStringRef &s, bool *ok = nullptr) const

Returns the short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toUShort() and toString().

short QLocale::toShort(QStringView s, bool *ok = nullptr) const

Returns the short int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toUShort() and toString().

QString QLocale::toString(qlonglong i) const

Returns a localized string representation of i.

See also toLongLong(), numberOptions(), zeroDigit(), and positiveSign().

QString QLocale::toString(qulonglong i) const

This is an overloaded function.

See also toULongLong(), numberOptions(), zeroDigit(), and positiveSign().

QString QLocale::toString(long i) const

This is an overloaded function.

See also toLong().

QString QLocale::toString(ulong i) const

This is an overloaded function.

See also toULong().

QString QLocale::toString(short i) const

This is an overloaded function.

See also toShort().

QString QLocale::toString(ushort i) const

This is an overloaded function.

See also toUShort().

QString QLocale::toString(int i) const

This is an overloaded function.

See also toInt().

QString QLocale::toString(uint i) const

This is an overloaded function.

See also toUInt().

QString QLocale::toString(double i, char f = 'g', int prec = 6) const

This is an overloaded function.

f and prec have the same meaning as in QString::number(double, char, int).

See also toDouble(), numberOptions(), exponential(), decimalPoint(), zeroDigit(), positiveSign(), and percent().

QString QLocale::toString(float i, char f = ..., int prec = ...) const

This is an overloaded function.

f and prec have the same meaning as in QString::number(double, char, int).

See also toDouble().

QString QLocale::toString(const QDate &date, const QString &format) const

Returns a localized string representation of the given date in the specified format. If format is an empty string, an empty string is returned.

See also QDate::toString().

QString QLocale::toString(const QTime &time, const QString &format) const

Returns a localized string representation of the given time according to the specified format. If format is an empty string, an empty string is returned.

See also QTime::toString().

QString QLocale::toString(const QDateTime &dateTime, const QString &format) const

Returns a localized string representation of the given dateTime according to the specified format. If format is an empty string, an empty string is returned.

This function was introduced in Qt 4.4.

See also QDateTime::toString(), QDate::toString(), and QTime::toString().

QString QLocale::toString(const QDate &date, QStringView format) const

Returns a localized string representation of the given date in the specified format. If format is an empty string, an empty string is returned.

This function was introduced in Qt 5.10.

See also QDate::toString().

QString QLocale::toString(const QTime &time, QStringView format) const

Returns a localized string representation of the given time according to the specified format. If format is an empty string, an empty string is returned.

This function was introduced in Qt 5.10.

See also QTime::toString().

QString QLocale::toString(const QDateTime &dateTime, QStringView format) const

Returns a localized string representation of the given dateTime according to the specified format. If format is an empty string, an empty string is returned.

This function was introduced in Qt 5.10.

See also QDateTime::toString(), QDate::toString(), and QTime::toString().

QString QLocale::toString(const QDate &date, QLocale::FormatType format = LongFormat) const

Returns a localized string representation of the given date according to the specified format.

QString QLocale::toString(const QTime &time, QLocale::FormatType format = LongFormat) const

Returns a localized string representation of the given time in the specified format.

QString QLocale::toString(const QDateTime &dateTime, QLocale::FormatType format = LongFormat) const

Returns a localized string representation of the given dateTime according to the specified format.

This function was introduced in Qt 4.4.

QTime QLocale::toTime(const QString &string, QLocale::FormatType format = LongFormat) const

Parses the time string given in string and returns the time. The format of the time string is chosen according to the format parameter (see timeFormat()).

If the time could not be parsed, returns an invalid time.

This function was introduced in Qt 4.4.

See also timeFormat(), toDate(), toDateTime(), and QTime::fromString().

QTime QLocale::toTime(const QString &string, const QString &format) const

Parses the time string given in string and returns the time. See QTime::fromString() for information on what is a valid format string.

If the time could not be parsed, returns an invalid time.

This function was introduced in Qt 4.4.

See also timeFormat(), toDate(), toDateTime(), and QTime::fromString().

QTime QLocale::toTime(const QString &string, QLocale::FormatType format, QCalendar cal) const

This is an overloaded function.

This function was introduced in Qt 5.14.

QTime QLocale::toTime(const QString &string, const QString &format, QCalendar cal) const

This is an overloaded function.

This function was introduced in Qt 5.14.

uint QLocale::toUInt(const QString &s, bool *ok = nullptr) const

Returns the unsigned int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See also toInt() and toString().

uint QLocale::toUInt(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toInt() and toString().

uint QLocale::toUInt(QStringView s, bool *ok = nullptr) const

Returns the unsigned int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toInt() and toString().

ulong QLocale::toULong(const QString &s, bool *ok = nullptr) const

Returns the unsigned long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.13.

See also toLong(), toInt(), toDouble(), and toString().

ulong QLocale::toULong(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.13.

See also toLong(), toInt(), toDouble(), and toString().

ulong QLocale::toULong(QStringView s, bool *ok = nullptr) const

Returns the unsigned long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.13.

See also toLong(), toInt(), toDouble(), and toString().

qulonglong QLocale::toULongLong(const QString &s, bool *ok = nullptr) const

Returns the unsigned long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See also toLongLong(), toInt(), toDouble(), and toString().

qulonglong QLocale::toULongLong(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toLongLong(), toInt(), toDouble(), and toString().

qulonglong QLocale::toULongLong(QStringView s, bool *ok = nullptr) const

Returns the unsigned long long int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toLongLong(), toInt(), toDouble(), and toString().

ushort QLocale::toUShort(const QString &s, bool *ok = nullptr) const

Returns the unsigned short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See also toShort() and toString().

ushort QLocale::toUShort(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See also toShort() and toString().

ushort QLocale::toUShort(QStringView s, bool *ok = nullptr) const

Returns the unsigned short int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See also toShort() and toString().

QString QLocale::toUpper(const QString &str) const

Returns an uppercase copy of str.

If Qt Core is using the ICU libraries, they will be used to perform the transformation according to the rules of the current locale. Otherwise the conversion may be done in a platform-dependent manner, with QString::toUpper() as a generic fallback.

This function was introduced in Qt 4.8.

See also QString::toUpper().

QStringList QLocale::uiLanguages() const

Returns an ordered list of locale names for translation purposes in preference order (like "en-Latn-US", "en-US", "en").

The return value represents locale names that the user expects to see the UI translation in.

Most like you do not need to use this function directly, but just pass the QLocale object to the QTranslator::load() function.

The first item in the list is the most preferred one.

This function was introduced in Qt 4.8.

See also QTranslator and bcp47Name().

QList<Qt::DayOfWeek> QLocale::weekdays() const

Returns a list of days that are considered weekdays according to the current locale.

This function was introduced in Qt 4.8.

QChar QLocale::zeroDigit() const

Returns the zero digit character of this locale.

Note: This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this.

This function was introduced in Qt 4.1.

See also toString().

bool QLocale::operator!=(const QLocale &other) const

Returns true if the QLocale object is not the same as the other locale specified; otherwise returns false.

bool QLocale::operator==(const QLocale &other) const

Returns true if the QLocale object is the same as the other locale specified; otherwise returns false.

Related Non-Members

uint qHash(const QLocale &key, uint seed = 0)

Returns the hash value for key, using seed to seed the calculation.

This function was introduced in Qt 5.6.

漏 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.