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:
- setDefault(const QLocale &locale)
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() |
Related Non-Members
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.
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.
Constant | Value | Description |
---|---|---|
QLocale::AnyCountry | 0 | Â |
QLocale::Afghanistan | 1 | Â |
QLocale::AlandIslands | 248 | Â |
QLocale::Albania | 2 | Â |
QLocale::Algeria | 3 | Â |
QLocale::AmericanSamoa | 4 | Â |
QLocale::Andorra | 5 | Â |
QLocale::Angola | 6 | Â |
QLocale::Anguilla | 7 | Â |
QLocale::Antarctica | 8 | Â |
QLocale::AntiguaAndBarbuda | 9 | Â |
QLocale::Argentina | 10 | Â |
QLocale::Armenia | 11 | Â |
QLocale::Aruba | 12 | Â |
QLocale::AscensionIsland | 247 | Â |
QLocale::Australia | 13 | Â |
QLocale::Austria | 14 | Â |
QLocale::Azerbaijan | 15 | Â |
QLocale::Bahamas | 16 | Â |
QLocale::Bahrain | 17 | Â |
QLocale::Bangladesh | 18 | Â |
QLocale::Barbados | 19 | Â |
QLocale::Belarus | 20 | Â |
QLocale::Belgium | 21 | Â |
QLocale::Belize | 22 | Â |
QLocale::Benin | 23 | Â |
QLocale::Bermuda | 24 | Â |
QLocale::Bhutan | 25 | Â |
QLocale::Bolivia | 26 | Â |
QLocale::Bonaire | 255 | Â |
QLocale::BosniaAndHerzegowina | 27 | Â |
QLocale::Botswana | 28 | Â |
QLocale::BouvetIsland | 29 | Â |
QLocale::Brazil | 30 | Â |
QLocale::BritishIndianOceanTerritory | 31 | Â |
QLocale::BritishVirginIslands | 233 | Â |
QLocale::Brunei | 32 | Â |
QLocale::Bulgaria | 33 | Â |
QLocale::BurkinaFaso | 34 | Â |
QLocale::Burundi | 35 | Â |
QLocale::Cambodia | 36 | Â |
QLocale::Cameroon | 37 | Â |
QLocale::Canada | 38 | Â |
QLocale::CanaryIslands | 238 | Â |
QLocale::CapeVerde | 39 | Â |
QLocale::CaymanIslands | 40 | Â |
QLocale::CentralAfricanRepublic | 41 | Â |
QLocale::CeutaAndMelilla | 250 | Â |
QLocale::Chad | 42 | Â |
QLocale::Chile | 43 | Â |
QLocale::China | 44 | Â |
QLocale::ChristmasIsland | 45 | Â |
QLocale::ClippertonIsland | 241 | Â |
QLocale::CocosIslands | 46 | Â |
QLocale::Colombia | 47 | Â |
QLocale::Comoros | 48 | Â |
QLocale::CongoBrazzaville | 50 | Â |
QLocale::CongoKinshasa | 49 | Â |
QLocale::CookIslands | 51 | Â |
QLocale::CostaRica | 52 | Â |
QLocale::Croatia | 54 | Â |
QLocale::Cuba | 55 | Â |
QLocale::CuraSao | 152 | Â |
QLocale::Cyprus | 56 | Â |
QLocale::CzechRepublic | 57 | Â |
QLocale::DemocraticRepublicOfCongo | CongoKinshasa | Obsolete, please use CongoKinshasa |
QLocale::DemocraticRepublicOfKorea | NorthKorea | Obsolete, please use NorthKorea |
QLocale::Denmark | 58 | Â |
QLocale::DiegoGarcia | 249 | Â |
QLocale::Djibouti | 59 | Â |
QLocale::Dominica | 60 | Â |
QLocale::DominicanRepublic | 61 | Â |
QLocale::EastTimor | 62 | Â |
QLocale::Ecuador | 63 | Â |
QLocale::Egypt | 64 | Â |
QLocale::ElSalvador | 65 | Â |
QLocale::EquatorialGuinea | 66 | Â |
QLocale::Eritrea | 67 | Â |
QLocale::Estonia | 68 | Â |
QLocale::Ethiopia | 69 | Â |
QLocale::EuropeanUnion | 258 | Since Qt 5.7 |
QLocale::Europe | 261 | Since Qt 5.12 |
QLocale::FalklandIslands | 70 | Â |
QLocale::FaroeIslands | 71 | Â |
QLocale::Fiji | 72 | Â |
QLocale::Finland | 73 | Â |
QLocale::France | 74 | Â |
QLocale::FrenchGuiana | 76 | Â |
QLocale::FrenchPolynesia | 77 | Â |
QLocale::FrenchSouthernTerritories | 78 | Â |
QLocale::Gabon | 79 | Â |
QLocale::Gambia | 80 | Â |
QLocale::Georgia | 81 | Â |
QLocale::Germany | 82 | Â |
QLocale::Ghana | 83 | Â |
QLocale::Gibraltar | 84 | Â |
QLocale::Greece | 85 | Â |
QLocale::Greenland | 86 | Â |
QLocale::Grenada | 87 | Â |
QLocale::Guadeloupe | 88 | Â |
QLocale::Guam | 89 | Â |
QLocale::Guatemala | 90 | Â |
QLocale::Guernsey | 75 | Â |
QLocale::Guinea | 91 | Â |
QLocale::GuineaBissau | 92 | Â |
QLocale::Guyana | 93 | Â |
QLocale::Haiti | 94 | Â |
QLocale::HeardAndMcDonaldIslands | 95 | Â |
QLocale::Honduras | 96 | Â |
QLocale::HongKong | 97 | Â |
QLocale::Hungary | 98 | Â |
QLocale::Iceland | 99 | Â |
QLocale::India | 100 | Â |
QLocale::Indonesia | 101 | Â |
QLocale::Iran | 102 | Â |
QLocale::Iraq | 103 | Â |
QLocale::Ireland | 104 | Â |
QLocale::IsleOfMan | 251 | Â |
QLocale::Israel | 105 | Â |
QLocale::Italy | 106 | Â |
QLocale::IvoryCoast | 53 | Â |
QLocale::Jamaica | 107 | Â |
QLocale::Japan | 108 | Â |
QLocale::Jersey | 252 | Â |
QLocale::Jordan | 109 | Â |
QLocale::Kazakhstan | 110 | Â |
QLocale::Kenya | 111 | Â |
QLocale::Kiribati | 112 | Â |
QLocale::Kosovo | 257 | Since Qt 5.2 |
QLocale::Kuwait | 115 | Â |
QLocale::Kyrgyzstan | 116 | Â |
QLocale::Laos | 117 | Â |
QLocale::LatinAmerica | 246 | Â |
QLocale::LatinAmericaAndTheCaribbean | LatinAmerica | Obsolete, please use LatinAmerica |
QLocale::Latvia | 118 | Â |
QLocale::Lebanon | 119 | Â |
QLocale::Lesotho | 120 | Â |
QLocale::Liberia | 121 | Â |
QLocale::Libya | 122 | Â |
QLocale::Liechtenstein | 123 | Â |
QLocale::Lithuania | 124 | Â |
QLocale::Luxembourg | 125 | Â |
QLocale::Macau | 126 | Â |
QLocale::Macedonia | 127 | Â |
QLocale::Madagascar | 128 | Â |
QLocale::Malawi | 129 | Â |
QLocale::Malaysia | 130 | Â |
QLocale::Maldives | 131 | Â |
QLocale::Mali | 132 | Â |
QLocale::Malta | 133 | Â |
QLocale::MarshallIslands | 134 | Â |
QLocale::Martinique | 135 | Â |
QLocale::Mauritania | 136 | Â |
QLocale::Mauritius | 137 | Â |
QLocale::Mayotte | 138 | Â |
QLocale::Mexico | 139 | Â |
QLocale::Micronesia | 140 | Â |
QLocale::Moldova | 141 | Â |
QLocale::Monaco | 142 | Â |
QLocale::Mongolia | 143 | Â |
QLocale::Montenegro | 242 | Â |
QLocale::Montserrat | 144 | Â |
QLocale::Morocco | 145 | Â |
QLocale::Mozambique | 146 | Â |
QLocale::Myanmar | 147 | Â |
QLocale::Namibia | 148 | Â |
QLocale::NauruCountry | 149 | Â |
QLocale::Nepal | 150 | Â |
QLocale::Netherlands | 151 | Â |
QLocale::NewCaledonia | 153 | Â |
QLocale::NewZealand | 154 | Â |
QLocale::Nicaragua | 155 | Â |
QLocale::Niger | 156 | Â |
QLocale::Nigeria | 157 | Â |
QLocale::Niue | 158 | Â |
QLocale::NorfolkIsland | 159 | Â |
QLocale::NorthernMarianaIslands | 160 | Â |
QLocale::NorthKorea | 113 | Â |
QLocale::Norway | 161 | Â |
QLocale::Oman | 162 | Â |
QLocale::OutlyingOceania | 259 | Since Qt 5.7 |
QLocale::Pakistan | 163 | Â |
QLocale::Palau | 164 | Â |
QLocale::PalestinianTerritories | 165 | Â |
QLocale::Panama | 166 | Â |
QLocale::PapuaNewGuinea | 167 | Â |
QLocale::Paraguay | 168 | Â |
QLocale::PeoplesRepublicOfCongo | CongoBrazzaville | Obsolete, please use CongoBrazzaville |
QLocale::Peru | 169 | Â |
QLocale::Philippines | 170 | Â |
QLocale::Pitcairn | 171 | Â |
QLocale::Poland | 172 | Â |
QLocale::Portugal | 173 | Â |
QLocale::PuertoRico | 174 | Â |
QLocale::Qatar | 175 | Â |
QLocale::RepublicOfKorea | SouthKorea | Obsolete, please use SouthKorea |
QLocale::Reunion | 176 | Â |
QLocale::Romania | 177 | Â |
QLocale::RussianFederation | Russia | same as Russia |
QLocale::Russia | 178 | same as RussianFederation |
QLocale::Rwanda | 179 | Â |
QLocale::SaintBarthelemy | 244 | Â |
QLocale::SaintHelena | 199 | Â |
QLocale::SaintKittsAndNevis | 180 | Â |
QLocale::SaintLucia | 181 | Â |
QLocale::SaintMartin | 245 | Â |
QLocale::SaintPierreAndMiquelon | 200 | Â |
QLocale::SaintVincentAndTheGrenadines | 182 | Â |
QLocale::Samoa | 183 | Â |
QLocale::SanMarino | 184 | Â |
QLocale::SaoTomeAndPrincipe | 185 | Â |
QLocale::SaudiArabia | 186 | Â |
QLocale::Senegal | 187 | Â |
QLocale::Serbia | 243 | Â |
QLocale::Seychelles | 188 | Â |
QLocale::SierraLeone | 189 | Â |
QLocale::Singapore | 190 | Â |
QLocale::SintMaarten | 256 | Â |
QLocale::Slovakia | 191 | Â |
QLocale::Slovenia | 192 | Â |
QLocale::SolomonIslands | 193 | Â |
QLocale::Somalia | 194 | Â |
QLocale::SouthAfrica | 195 | Â |
QLocale::SouthGeorgiaAndTheSouthSandwichIslands | 196 | Â |
QLocale::SouthKorea | 114 | Â |
QLocale::SouthSudan | 254 | Â |
QLocale::Spain | 197 | Â |
QLocale::SriLanka | 198 | Â |
QLocale::Sudan | 201 | Â |
QLocale::Suriname | 202 | Â |
QLocale::SvalbardAndJanMayenIslands | 203 | Â |
QLocale::Swaziland | 204 | Â |
QLocale::Sweden | 205 | Â |
QLocale::Switzerland | 206 | Â |
QLocale::Syria | 207 | Â |
QLocale::SyrianArabRepublic | Syria | Obsolete, please use Syria |
QLocale::Taiwan | 208 | Â |
QLocale::Tajikistan | 209 | Â |
QLocale::Tanzania | 210 | Â |
QLocale::Thailand | 211 | Â |
QLocale::Togo | 212 | Â |
QLocale::TokelauCountry | 213 | Â |
QLocale::Tokelau | TokelauCountry | Obsolete, please use TokelauCountry |
QLocale::Tonga | 214 | Â |
QLocale::TrinidadAndTobago | 215 | Â |
QLocale::TristanDaCunha | 253 | Â |
QLocale::Tunisia | 216 | Â |
QLocale::Turkey | 217 | Â |
QLocale::Turkmenistan | 218 | Â |
QLocale::TurksAndCaicosIslands | 219 | Â |
QLocale::TuvaluCountry | 220 | Â |
QLocale::Tuvalu | TuvaluCountry | Obsolete, please use TuvaluCountry |
QLocale::Uganda | 221 | Â |
QLocale::Ukraine | 222 | Â |
QLocale::UnitedArabEmirates | 223 | Â |
QLocale::UnitedKingdom | 224 | Â |
QLocale::UnitedStates | 225 | Â |
QLocale::UnitedStatesMinorOutlyingIslands | 226 | Â |
QLocale::UnitedStatesVirginIslands | 234 | Â |
QLocale::Uruguay | 227 | Â |
QLocale::Uzbekistan | 228 | Â |
QLocale::Vanuatu | 229 | Â |
QLocale::VaticanCityState | 230 | Â |
QLocale::Venezuela | 231 | Â |
QLocale::Vietnam | 232 | Â |
QLocale::WallisAndFutunaIslands | 235 | Â |
QLocale::WesternSahara | 236 | Â |
QLocale::World | 260 | Since Qt 5.12 |
QLocale::Yemen | 237 | Â |
QLocale::Zambia | 239 | Â |
QLocale::Zimbabwe | 240 | Â |
See also country() and countryToString().
enum QLocale::CurrencySymbolFormat
Specifies the format of the currency symbol.
Constant | Value | Description |
---|---|---|
QLocale::CurrencyIsoCode | 0 | a ISO-4217 code of the currency. |
QLocale::CurrencySymbol | 1 | a currency symbol. |
QLocale::CurrencyDisplayName | 2 | a 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.
Constant | Value | Description |
---|---|---|
QLocale::DataSizeIecFormat | 0 | format using base 1024 and IEC prefixes: KiB, MiB, GiB, ... |
QLocale::DataSizeTraditionalFormat | DataSizeSIQuantifiers | format using base 1024 and SI prefixes: kB, MB, GB, ... |
QLocale::DataSizeSIFormat | DataSizeBase1000 | DataSizeSIQuantifiers | format 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.
Constant | Value | Description |
---|---|---|
QLocale::FloatingPointShortest | -128 | The 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.
Constant | Value | Description |
---|---|---|
QLocale::LongFormat | 0 | The long version of day and month names; for example, returning "January" as a month name. |
QLocale::ShortFormat | 1 | The short version of day and month names; for example, returning "Jan" as a month name. |
QLocale::NarrowFormat | 2 | A 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.
Constant | Value | Description |
---|---|---|
QLocale::AnyLanguage | 0 | Â |
QLocale::C | 1 | A simplified English locale; see QLocale::c() |
QLocale::Abkhazian | 2 | Â |
QLocale::Afan | Oromo | Obsolete, please use Oromo |
QLocale::Afar | 4 | Â |
QLocale::Afrikaans | 5 | Â |
QLocale::Aghem | 237 | Â |
QLocale::Ahom | 340 | Since Qt 5.7 |
QLocale::Akan | 146 | Â |
QLocale::Akkadian | 262 | Since Qt 5.1 |
QLocale::Akoose | 312 | Since Qt 5.3 |
QLocale::Albanian | 6 | Â |
QLocale::AmericanSignLanguage | 341 | Since Qt 5.7 |
QLocale::Amharic | 7 | Â |
QLocale::AncientEgyptian | 263 | Since Qt 5.1 |
QLocale::AncientGreek | 264 | Since Qt 5.1 |
QLocale::AncientNorthArabian | 331 | Since Qt 5.5 |
QLocale::Arabic | 8 | Â |
QLocale::Aragonese | 261 | Since Qt 5.1 |
QLocale::Aramaic | 265 | Since Qt 5.1 |
QLocale::ArdhamagadhiPrakrit | 342 | Since Qt 5.7 |
QLocale::Armenian | 9 | Â |
QLocale::Assamese | 10 | Â |
QLocale::Asturian | 256 | Â |
QLocale::Asu | 205 | Â |
QLocale::Atsam | 156 | Â |
QLocale::Avaric | 216 | Â |
QLocale::Avestan | 255 | Â |
QLocale::Aymara | 11 | Â |
QLocale::Azerbaijani | 12 | Â |
QLocale::Bafia | 243 | Â |
QLocale::Balinese | 266 | Since Qt 5.1 |
QLocale::Bambara | 188 | Â |
QLocale::Bamun | 267 | Since Qt 5.1 |
QLocale::Basaa | 238 | Â |
QLocale::Bashkir | 13 | Â |
QLocale::Basque | 14 | Â |
QLocale::Bassa | 336 | Since Qt 5.5 |
QLocale::BatakToba | 268 | Since Qt 5.1 |
QLocale::Belarusian | 22 | Â |
QLocale::Bemba | 195 | Â |
QLocale::Bena | 186 | Â |
QLocale::Bengali | 15 | Â |
QLocale::Bhojpuri | 343 | Since Qt 5.7 |
QLocale::Bhutani | Dzongkha | Obsolete, please use Dzongkha |
QLocale::Bihari | 17 | Â |
QLocale::Bislama | 18 | Â |
QLocale::Blin | 152 | Â |
QLocale::Bodo | 215 | Â |
QLocale::Bosnian | 142 | Â |
QLocale::Breton | 19 | Â |
QLocale::Buginese | 269 | Since Qt 5.1 |
QLocale::Buhid | 270 | Since Qt 5.1 |
QLocale::Bulgarian | 20 | Â |
QLocale::Burmese | 21 | Â |
QLocale::Byelorussian | Belarusian | Obsolete, please use Belarusian |
QLocale::Cambodian | Khmer | Obsolete, please use Khmer |
QLocale::Cantonese | 357 | Since Qt 5.7 |
QLocale::Carian | 271 | Since Qt 5.1 |
QLocale::Catalan | 24 | Â |
QLocale::Cebuano | 365 | Since Qt 5.14 |
QLocale::CentralKurdish | 316 | Since Qt 5.5 |
QLocale::CentralMoroccoTamazight | 212 | Â |
QLocale::Chakma | 272 | Since Qt 5.1 |
QLocale::Chamorro | 217 | Â |
QLocale::Chechen | 218 | Â |
QLocale::Cherokee | 190 | Â |
QLocale::Chewa | Nyanja | Obsolete, please use Nyanja |
QLocale::Chickasaw | 367 | Since Qt 5.14 |
QLocale::Chiga | 211 | Â |
QLocale::Chinese | 25 | (Mandarin) |
QLocale::Church | 219 | Â |
QLocale::Chuvash | 220 | Â |
QLocale::ClassicalMandaic | 273 | Since Qt 5.1 |
QLocale::Colognian | 201 | Â |
QLocale::CongoSwahili | 250 | Â |
QLocale::Coptic | 274 | Since Qt 5.1 |
QLocale::Cornish | 145 | Â |
QLocale::Corsican | 26 | Â |
QLocale::Cree | 221 | Â |
QLocale::Croatian | 27 | Â |
QLocale::Czech | 28 | Â |
QLocale::Danish | 29 | Â |
QLocale::Divehi | 143 | Â |
QLocale::Dogri | 275 | Since Qt 5.1 |
QLocale::Duala | 240 | Â |
QLocale::Dutch | 30 | Â |
QLocale::Dzongkha | 16 | Â |
QLocale::EasternCham | 276 | Since Qt 5.1 |
QLocale::EasternKayah | 277 | Since Qt 5.1 |
QLocale::Embu | 189 | Â |
QLocale::English | 31 | Â |
QLocale::Erzya | 366 | Since Qt 5.14 |
QLocale::Esperanto | 32 | Â |
QLocale::Estonian | 33 | Â |
QLocale::Etruscan | 278 | Since Qt 5.1 |
QLocale::Ewe | 161 | Â |
QLocale::Ewondo | 242 | Â |
QLocale::Faroese | 34 | Â |
QLocale::Fijian | 35 | Â |
QLocale::Filipino | 166 | Â |
QLocale::Finnish | 36 | Â |
QLocale::French | 37 | Â |
QLocale::Frisian | WesternFrisian | same as WesternFrisian |
QLocale::Friulian | 159 | Â |
QLocale::Fulah | 177 | Â |
QLocale::Ga | 148 | Â |
QLocale::Gaelic | 39 | Â |
QLocale::Galician | 40 | Â |
QLocale::Ganda | 194 | Â |
QLocale::Geez | 153 | Â |
QLocale::Georgian | 41 | Â |
QLocale::German | 42 | Â |
QLocale::Gothic | 279 | Since Qt 5.1 |
QLocale::Greek | 43 | Â |
QLocale::Greenlandic | 44 | Â |
QLocale::Guarani | 45 | Â |
QLocale::Gujarati | 46 | Â |
QLocale::Gusii | 175 | Â |
QLocale::Haitian | 222 | Â |
QLocale::Hanunoo | 280 | Since Qt 5.1 |
QLocale::Hausa | 47 | Â |
QLocale::Hawaiian | 163 | Â |
QLocale::Hebrew | 48 | Â |
QLocale::Herero | 223 | Â |
QLocale::HieroglyphicLuwian | 344 | Since Qt 5.7 |
QLocale::Hindi | 49 | Â |
QLocale::HiriMotu | 224 | Â |
QLocale::HmongNjua | 333 | Since Qt 5.5 |
QLocale::Ho | 334 | Since Qt 5.5 |
QLocale::Hungarian | 50 | Â |
QLocale::Icelandic | 51 | Â |
QLocale::Ido | 360 | Since Qt 5.12 |
QLocale::Igbo | 149 | Â |
QLocale::InariSami | 326 | Since Qt 5.5 |
QLocale::Indonesian | 52 | Â |
QLocale::Ingush | 281 | Since Qt 5.1 |
QLocale::Interlingua | 53 | Â |
QLocale::Interlingue | 54 | Â |
QLocale::Inuktitut | 55 | Â |
QLocale::Inupiak | 56 | Â |
QLocale::Irish | 57 | Â |
QLocale::Italian | 58 | Â |
QLocale::Japanese | 59 | Â |
QLocale::Javanese | 60 | Â |
QLocale::Jju | 158 | Â |
QLocale::JolaFonyi | 241 | Â |
QLocale::Kabuverdianu | 196 | Â |
QLocale::Kabyle | 184 | Â |
QLocale::Kako | 258 | Â |
QLocale::Kalenjin | 198 | Â |
QLocale::Kamba | 150 | Â |
QLocale::Kannada | 61 | Â |
QLocale::Kanuri | 225 | Â |
QLocale::Kashmiri | 62 | Â |
QLocale::Kazakh | 63 | Â |
QLocale::Kenyang | 319 | Since Qt 5.5 |
QLocale::Khmer | 23 | Â |
QLocale::Kiche | 323 | Since Qt 5.5 |
QLocale::Kikuyu | 178 | Â |
QLocale::Kinyarwanda | 64 | Â |
QLocale::Kirghiz | 65 | Â |
QLocale::Komi | 226 | Â |
QLocale::Kongo | 227 | Â |
QLocale::Konkani | 147 | Â |
QLocale::Korean | 66 | Â |
QLocale::Koro | 154 | Â |
QLocale::KoyraboroSenni | 213 | Â |
QLocale::KoyraChiini | 208 | Â |
QLocale::Kpelle | 169 | Â |
QLocale::Kurdish | 67 | Â |
QLocale::Kurundi | Rundi | Obsolete, please use Rundi |
QLocale::Kwanyama | 228 | Â |
QLocale::Kwasio | 246 | Â |
QLocale::Lakota | 313 | Since Qt 5.3 |
QLocale::Langi | 193 | Â |
QLocale::Lao | 69 | Â |
QLocale::LargeFloweryMiao | 282 | Since Qt 5.1 |
QLocale::Latin | 70 | Â |
QLocale::Latvian | 71 | Â |
QLocale::Lepcha | 283 | Since Qt 5.1 |
QLocale::Lezghian | 335 | Since Qt 5.5 |
QLocale::Limburgish | 229 | Â |
QLocale::Limbu | 284 | Since Qt 5.1 |
QLocale::LinearA | 332 | Since Qt 5.5 |
QLocale::Lingala | 72 | Â |
QLocale::Lisu | 285 | Since Qt 5.1 |
QLocale::LiteraryChinese | 345 | Since Qt 5.7 |
QLocale::Lithuanian | 73 | Â |
QLocale::Lojban | 361 | Since Qt 5.12 |
QLocale::LowerSorbian | 317 | Since Qt 5.5 |
QLocale::LowGerman | 170 | Â |
QLocale::LubaKatanga | 230 | Â |
QLocale::LuleSami | 325 | Since Qt 5.5 |
QLocale::Luo | 210 | Â |
QLocale::Lu | 286 | Since Qt 5.1 |
QLocale::Luxembourgish | 231 | Â |
QLocale::Luyia | 204 | Â |
QLocale::Lycian | 287 | Since Qt 5.1 |
QLocale::Lydian | 288 | Since Qt 5.1 |
QLocale::Macedonian | 74 | Â |
QLocale::Machame | 200 | Â |
QLocale::Maithili | 339 | Since Qt 5.5 |
QLocale::MakhuwaMeetto | 244 | Â |
QLocale::Makonde | 192 | Â |
QLocale::Malagasy | 75 | Â |
QLocale::Malay | 76 | Â |
QLocale::Malayalam | 77 | Â |
QLocale::Maltese | 78 | Â |
QLocale::Mandingo | 289 | Since Qt 5.1 |
QLocale::ManichaeanMiddlePersian | 329 | Since Qt 5.5 |
QLocale::Manipuri | 290 | Since Qt 5.1 |
QLocale::Manx | 144 | Â |
QLocale::Maori | 79 | Â |
QLocale::Mapuche | 315 | Since Qt 5.5 |
QLocale::Marathi | 80 | Â |
QLocale::Marshallese | 81 | Â |
QLocale::Masai | 202 | Â |
QLocale::Mazanderani | 346 | Since Qt 5.7 |
QLocale::Mende | 330 | Since Qt 5.5 |
QLocale::Meroitic | 291 | Since Qt 5.1 |
QLocale::Meru | 197 | Â |
QLocale::Meta | 259 | Â |
QLocale::Mohawk | 320 | Since Qt 5.5 |
QLocale::Moldavian | Romanian | Obsolete, please use Romanian |
QLocale::Mongolian | 82 | Â |
QLocale::Mono | 337 | Since Qt 5.5 |
QLocale::Morisyen | 191 | Â |
QLocale::Mru | 347 | Since Qt 5.7 |
QLocale::Mundang | 245 | Â |
QLocale::Muscogee | 368 | Since Qt 5.14 |
QLocale::Nama | 199 | Â |
QLocale::NauruLanguage | 83 | Â |
QLocale::Navaho | 232 | Â |
QLocale::Ndonga | 233 | Â |
QLocale::Nepali | 84 | Â |
QLocale::Newari | 348 | Since Qt 5.7 |
QLocale::Ngiemboon | 260 | Â |
QLocale::Ngomba | 257 | Â |
QLocale::Nko | 321 | Since Qt 5.5 |
QLocale::NorthernLuri | 349 | Since Qt 5.7 |
QLocale::NorthernSami | 173 | Â |
QLocale::NorthernSotho | 172 | Â |
QLocale::NorthernThai | 292 | Since Qt 5.1 |
QLocale::NorthNdebele | 181 | Â |
QLocale::NorwegianBokmal | 85 | same as Norwegian |
QLocale::NorwegianNynorsk | 141 | Â |
QLocale::Norwegian | NorwegianBokmal | same as NorwegianBokmal |
QLocale::Nuer | 247 | Â |
QLocale::Nyanja | 165 | Â |
QLocale::Nyankole | 185 | Â |
QLocale::Occitan | 86 | Â |
QLocale::Ojibwa | 234 | Â |
QLocale::OldIrish | 293 | Since Qt 5.1 |
QLocale::OldNorse | 294 | Since Qt 5.1 |
QLocale::OldPersian | 295 | Since Qt 5.1 |
QLocale::OldTurkish | 296 | Since Qt 5.1 |
QLocale::Oriya | 87 | Â |
QLocale::Oromo | 3 | Â |
QLocale::Osage | 358 | Since Qt 5.7 |
QLocale::Ossetic | 101 | Â |
QLocale::Pahlavi | 297 | Since Qt 5.1 |
QLocale::Palauan | 350 | Since Qt 5.7 |
QLocale::Pali | 235 | Â |
QLocale::Papiamento | 351 | Since Qt 5.7 |
QLocale::Parthian | 298 | Since Qt 5.1 |
QLocale::Pashto | 88 | Â |
QLocale::Persian | 89 | Â |
QLocale::Phoenician | 299 | Since Qt 5.1 |
QLocale::Polish | 90 | Â |
QLocale::Portuguese | 91 | Â |
QLocale::PrakritLanguage | 300 | Since Qt 5.1 |
QLocale::Prussian | 322 | Since Qt 5.5 |
QLocale::Punjabi | 92 | Â |
QLocale::Quechua | 93 | Â |
QLocale::Rejang | 301 | Since Qt 5.1 |
QLocale::RhaetoRomance | Romansh | Obsolete, please use Romansh |
QLocale::Romanian | 95 | Â |
QLocale::Romansh | 94 | Â |
QLocale::Rombo | 182 | Â |
QLocale::Rundi | 68 | Â |
QLocale::Russian | 96 | Â |
QLocale::Rwa | 209 | Â |
QLocale::Sabaean | 302 | Since Qt 5.1 |
QLocale::Saho | 207 | Â |
QLocale::Sakha | 248 | Â |
QLocale::Samaritan | 303 | Since Qt 5.1 |
QLocale::Samburu | 179 | Â |
QLocale::Samoan | 97 | Â |
QLocale::Sango | 98 | Â |
QLocale::Sangu | 249 | Â |
QLocale::Sanskrit | 99 | Â |
QLocale::Santali | 304 | Since Qt 5.1 |
QLocale::Saraiki | 352 | Since Qt 5.7 |
QLocale::Sardinian | 115 | Â |
QLocale::Saurashtra | 305 | Since Qt 5.1 |
QLocale::Sena | 180 | Â |
QLocale::Serbian | 100 | Â |
QLocale::SerboCroatian | Serbian | Obsolete, please use Serbian |
QLocale::Shambala | 214 | Â |
QLocale::Shona | 104 | Â |
QLocale::SichuanYi | 168 | Â |
QLocale::Sicilian | 362 | Since Qt 5.12 |
QLocale::Sidamo | 155 | Â |
QLocale::Silesian | 369 | Since Qt 5.14 |
QLocale::Sindhi | 105 | Â |
QLocale::Sinhala | 106 | Â |
QLocale::SkoltSami | 327 | Since Qt 5.5 |
QLocale::Slovak | 108 | Â |
QLocale::Slovenian | 109 | Â |
QLocale::Soga | 203 | Â |
QLocale::Somali | 110 | Â |
QLocale::Sora | 306 | Since Qt 5.1 |
QLocale::SouthernKurdish | 363 | Since Qt 5.12 |
QLocale::SouthernSami | 324 | Since Qt 5.5 |
QLocale::SouthernSotho | 102 | Â |
QLocale::SouthNdebele | 171 | Â |
QLocale::Spanish | 111 | Â |
QLocale::StandardMoroccanTamazight | 314 | Since Qt 5.3 |
QLocale::Sundanese | 112 | Â |
QLocale::Swahili | 113 | Â |
QLocale::Swati | 107 | Â |
QLocale::Swedish | 114 | Â |
QLocale::SwissGerman | 167 | Â |
QLocale::Sylheti | 307 | Since Qt 5.1 |
QLocale::Syriac | 151 | Â |
QLocale::Tachelhit | 183 | Â |
QLocale::Tagalog | Filipino | Obsolete, please use Filipino |
QLocale::Tagbanwa | 308 | Since Qt 5.1 |
QLocale::Tahitian | 127 | Â |
QLocale::TaiDam | 309 | Since Qt 5.1 |
QLocale::TaiNua | 310 | Since Qt 5.1 |
QLocale::Taita | 176 | Â |
QLocale::Tajik | 116 | Â |
QLocale::Tamil | 117 | Â |
QLocale::Tangut | 359 | Since Qt 5.7 |
QLocale::Taroko | 174 | Â |
QLocale::Tasawaq | 251 | Â |
QLocale::Tatar | 118 | Â |
QLocale::TedimChin | 338 | Since Qt 5.5 |
QLocale::Telugu | 119 | Â |
QLocale::Teso | 206 | Â |
QLocale::Thai | 120 | Â |
QLocale::Tibetan | 121 | Â |
QLocale::Tigre | 157 | Â |
QLocale::Tigrinya | 122 | Â |
QLocale::TokelauLanguage | 353 | Since Qt 5.7 |
QLocale::TokPisin | 354 | Since Qt 5.7 |
QLocale::Tongan | 123 | Â |
QLocale::Tsonga | 124 | Â |
QLocale::Tswana | 103 | Â |
QLocale::Turkish | 125 | Â |
QLocale::Turkmen | 126 | Â |
QLocale::TuvaluLanguage | 355 | Since Qt 5.7 |
QLocale::Twi | Akan | Obsolete, please use Akan |
QLocale::Tyap | 164 | Â |
QLocale::Ugaritic | 311 | Since Qt 5.1 |
QLocale::Uighur | 128 | Â |
QLocale::Uigur | Uighur | Obsolete, please use Uighur |
QLocale::Ukrainian | 129 | Â |
QLocale::UncodedLanguages | 356 | Since Qt 5.7 |
QLocale::UpperSorbian | 318 | Since Qt 5.5 |
QLocale::Urdu | 130 | Â |
QLocale::Uzbek | 131 | Â |
QLocale::Vai | 252 | Â |
QLocale::Venda | 160 | Â |
QLocale::Vietnamese | 132 | Â |
QLocale::Volapuk | 133 | Â |
QLocale::Vunjo | 187 | Â |
QLocale::Walamo | 162 | Â |
QLocale::Walloon | 236 | Â |
QLocale::Walser | 253 | Â |
QLocale::Warlpiri | 328 | Since Qt 5.5 |
QLocale::Welsh | 134 | Â |
QLocale::WesternBalochi | 364 | Since Qt 5.12 |
QLocale::WesternFrisian | 38 | same as Frisian |
QLocale::Wolof | 135 | Â |
QLocale::Xhosa | 136 | Â |
QLocale::Yangben | 254 | Â |
QLocale::Yiddish | 137 | Â |
QLocale::Yoruba | 138 | Â |
QLocale::Zarma | 239 | Â |
QLocale::Zhuang | 139 | Â |
QLocale::Zulu | 140 | Â |
See also language() and languageToString().
enum QLocale::MeasurementSystem
This enum defines which units are used for measurement.
Constant | Value | Description |
---|---|---|
QLocale::MetricSystem | 0 | This value indicates metric units, such as meters, centimeters and millimeters. |
QLocale::ImperialUSSystem | 1 | This value indicates imperial units, such as inches and miles as they are used in the United States. |
QLocale::ImperialUKSystem | 2 | This value indicates imperial units, such as inches and miles as they are used in the United Kingdom. |
QLocale::ImperialSystem | ImperialUSSystem | Provided 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().
Constant | Value | Description |
---|---|---|
QLocale::DefaultNumberOptions | 0x0 | This 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::OmitGroupSeparator | 0x01 | If 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::RejectGroupSeparator | 0x02 | If 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::OmitLeadingZeroInExponent | 0x04 | If 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::RejectLeadingZeroInExponent | 0x08 | If 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::IncludeTrailingZeroesAfterDot | 0x10 | If 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::RejectTrailingZeroesAfterDot | 0x20 | If 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.
Constant | Value | Description |
---|---|---|
QLocale::StandardQuotation | 0 | If this option is set, the standard quotation marks will be used to quote strings. |
QLocale::AlternateQuotation | 1 | If 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.
Constant | Value | Description |
---|---|---|
QLocale::AnyScript | 0 | Â |
QLocale::AdlamScript | 134 | Since Qt 5.7 |
QLocale::AhomScript | 128 | Since Qt 5.7 |
QLocale::AnatolianHieroglyphsScript | 129 | Since Qt 5.7 |
QLocale::ArabicScript | 1 | Â |
QLocale::ArmenianScript | 10 | Â |
QLocale::AvestanScript | 36 | Since Qt 5.1 |
QLocale::BalineseScript | 37 | Since Qt 5.1 |
QLocale::BamumScript | 38 | Since Qt 5.1 |
QLocale::BassaVahScript | 106 | Since Qt 5.5 |
QLocale::BatakScript | 39 | Since Qt 5.1 |
QLocale::BengaliScript | 11 | Â |
QLocale::BhaiksukiScript | 135 | Since Qt 5.7 |
QLocale::BopomofoScript | 40 | Since Qt 5.1 |
QLocale::BrahmiScript | 41 | Since Qt 5.1 |
QLocale::BrailleScript | 103 | Since Qt 5.1 |
QLocale::BugineseScript | 42 | Since Qt 5.1 |
QLocale::BuhidScript | 43 | Since Qt 5.1 |
QLocale::CanadianAboriginalScript | 44 | Since Qt 5.1 |
QLocale::CarianScript | 45 | Since Qt 5.1 |
QLocale::CaucasianAlbanianScript | 105 | Since Qt 5.5 |
QLocale::ChakmaScript | 46 | Since Qt 5.1 |
QLocale::ChamScript | 47 | Since Qt 5.1 |
QLocale::CherokeeScript | 12 | Â |
QLocale::CopticScript | 48 | Since Qt 5.1 |
QLocale::CuneiformScript | 94 | Since Qt 5.1 |
QLocale::CypriotScript | 49 | Since Qt 5.1 |
QLocale::CyrillicScript | 2 | Â |
QLocale::DeseretScript | 3 | Since Qt 5.1 |
QLocale::DevanagariScript | 13 | Â |
QLocale::DuployanScript | 107 | Since Qt 5.5 |
QLocale::EgyptianHieroglyphsScript | 50 | Since Qt 5.1 |
QLocale::ElbasanScript | 108 | Since Qt 5.5 |
QLocale::EthiopicScript | 14 | Â |
QLocale::FraserScript | 51 | Since Qt 5.1 |
QLocale::GeorgianScript | 15 | Â |
QLocale::GlagoliticScript | 52 | Since Qt 5.1 |
QLocale::GothicScript | 53 | Since Qt 5.1 |
QLocale::GranthaScript | 109 | Since Qt 5.5 |
QLocale::GreekScript | 16 | Â |
QLocale::GujaratiScript | 17 | Â |
QLocale::GurmukhiScript | 4 | Â |
QLocale::HangulScript | 55 | Since Qt 5.1 |
QLocale::HanScript | 54 | Since Qt 5.1 |
QLocale::HanunooScript | 56 | Since Qt 5.1 |
QLocale::HanWithBopomofoScript | 140 | Since Qt 5.7 |
QLocale::HatranScript | 130 | Since Qt 5.7 |
QLocale::HebrewScript | 18 | Â |
QLocale::HiraganaScript | 104 | Since Qt 5.1 |
QLocale::ImperialAramaicScript | 57 | Since Qt 5.1 |
QLocale::InscriptionalPahlaviScript | 58 | Since Qt 5.1 |
QLocale::InscriptionalParthianScript | 59 | Since Qt 5.1 |
QLocale::JamoScript | 141 | Since Qt 5.7 |
QLocale::JapaneseScript | 19 | Â |
QLocale::JavaneseScript | 60 | Since Qt 5.1 |
QLocale::KaithiScript | 61 | Since Qt 5.1 |
QLocale::KannadaScript | 21 | Â |
QLocale::KatakanaScript | 62 | Since Qt 5.1 |
QLocale::KayahLiScript | 63 | Since Qt 5.1 |
QLocale::KharoshthiScript | 64 | Since Qt 5.1 |
QLocale::KhmerScript | 20 | Since Qt 5.1 |
QLocale::KhojkiScript | 111 | Since Qt 5.5 |
QLocale::KhudawadiScript | 125 | Since Qt 5.5 |
QLocale::KoreanScript | 22 | Â |
QLocale::LannaScript | 65 | Since Qt 5.1 |
QLocale::LaoScript | 23 | Â |
QLocale::LatinScript | 7 | Â |
QLocale::LepchaScript | 66 | Since Qt 5.1 |
QLocale::LimbuScript | 67 | Since Qt 5.1 |
QLocale::LinearAScript | 112 | Since Qt 5.5 |
QLocale::LinearBScript | 68 | Since Qt 5.1 |
QLocale::LycianScript | 69 | Since Qt 5.1 |
QLocale::LydianScript | 70 | Since Qt 5.1 |
QLocale::MahajaniScript | 113 | Since Qt 5.5 |
QLocale::MalayalamScript | 24 | Â |
QLocale::MandaeanScript | 71 | Since Qt 5.1 |
QLocale::ManichaeanScript | 114 | Since Qt 5.5 |
QLocale::MarchenScript | 136 | Since Qt 5.7 |
QLocale::MeiteiMayekScript | 72 | Since Qt 5.1 |
QLocale::MendeKikakuiScript | 115 | Since Qt 5.5 |
QLocale::MeroiticCursiveScript | 74 | Since Qt 5.1 |
QLocale::MeroiticScript | 73 | Since Qt 5.1 |
QLocale::ModiScript | 116 | Since Qt 5.5 |
QLocale::MongolianScript | 8 | Â |
QLocale::MroScript | 117 | Since Qt 5.5 |
QLocale::MultaniScript | 131 | Since Qt 5.7 |
QLocale::MyanmarScript | 25 | Â |
QLocale::NabataeanScript | 119 | Since Qt 5.5 |
QLocale::NewaScript | 137 | Since Qt 5.7 |
QLocale::NewTaiLueScript | 76 | Since Qt 5.1 |
QLocale::NkoScript | 75 | Since Qt 5.1 |
QLocale::OghamScript | 77 | Since Qt 5.1 |
QLocale::OlChikiScript | 78 | Since Qt 5.1 |
QLocale::OldHungarianScript | 132 | Since Qt 5.7 |
QLocale::OldItalicScript | 79 | Since Qt 5.1 |
QLocale::OldNorthArabianScript | 118 | Since Qt 5.5 |
QLocale::OldPermicScript | 122 | Since Qt 5.5 |
QLocale::OldPersianScript | 80 | Since Qt 5.1 |
QLocale::OldSouthArabianScript | 81 | Since Qt 5.1 |
QLocale::OriyaScript | 26 | Â |
QLocale::OrkhonScript | 82 | Since Qt 5.1 |
QLocale::OsageScript | 138 | Since Qt 5.7 |
QLocale::OsmanyaScript | 83 | Since Qt 5.1 |
QLocale::PahawhHmongScript | 110 | Since Qt 5.5 |
QLocale::PalmyreneScript | 120 | Since Qt 5.5 |
QLocale::PauCinHauScript | 121 | Since Qt 5.5 |
QLocale::PhagsPaScript | 84 | Since Qt 5.1 |
QLocale::PhoenicianScript | 85 | Since Qt 5.1 |
QLocale::PollardPhoneticScript | 86 | Since Qt 5.1 |
QLocale::PsalterPahlaviScript | 123 | Since Qt 5.5 |
QLocale::RejangScript | 87 | Since Qt 5.1 |
QLocale::RunicScript | 88 | Since Qt 5.1 |
QLocale::SamaritanScript | 89 | Since Qt 5.1 |
QLocale::SaurashtraScript | 90 | Since Qt 5.1 |
QLocale::SharadaScript | 91 | Since Qt 5.1 |
QLocale::ShavianScript | 92 | Since Qt 5.1 |
QLocale::SiddhamScript | 124 | Since Qt 5.5 |
QLocale::SignWritingScript | 133 | Since Qt 5.7 |
QLocale::SimplifiedChineseScript | SimplifiedHanScript | same as SimplifiedHanScript |
QLocale::SimplifiedHanScript | 5 | same as SimplifiedChineseScript |
QLocale::SinhalaScript | 32 | Â |
QLocale::SoraSompengScript | 93 | Since Qt 5.1 |
QLocale::SundaneseScript | 95 | Since Qt 5.1 |
QLocale::SylotiNagriScript | 96 | Since Qt 5.1 |
QLocale::SyriacScript | 33 | Â |
QLocale::TagalogScript | 97 | Since Qt 5.1 |
QLocale::TagbanwaScript | 98 | Since Qt 5.1 |
QLocale::TaiLeScript | 99 | Since Qt 5.1 |
QLocale::TaiVietScript | 100 | Since Qt 5.1 |
QLocale::TakriScript | 101 | Since Qt 5.1 |
QLocale::TamilScript | 27 | Â |
QLocale::TangutScript | 139 | Since Qt 5.7 |
QLocale::TeluguScript | 28 | Â |
QLocale::ThaanaScript | 29 | Â |
QLocale::ThaiScript | 30 | Â |
QLocale::TibetanScript | 31 | Â |
QLocale::TifinaghScript | 9 | Â |
QLocale::TirhutaScript | 126 | Since Qt 5.5 |
QLocale::TraditionalChineseScript | TraditionalHanScript | same as TraditionalHanScript |
QLocale::TraditionalHanScript | 6 | same as TraditionalChineseScript |
QLocale::UgariticScript | 102 | Since Qt 5.1 |
QLocale::VaiScript | 35 | Â |
QLocale::VarangKshitiScript | 127 | Since Qt 5.5 |
QLocale::YiScript | 34 | Â |
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.
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
.
© 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.