Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Private Functions | Properties | Friends | List of all members
QLocale Class Reference

#include <qlocale.h>

Classes

struct  Data
 

Public Types

enum  Country {
  AnyCountry = 0, Afghanistan = 1, Albania = 2, Algeria = 3,
  AmericanSamoa = 4, Andorra = 5, Angola = 6, Anguilla = 7,
  Antarctica = 8, AntiguaAndBarbuda = 9, Argentina = 10, Armenia = 11,
  Aruba = 12, Australia = 13, Austria = 14, Azerbaijan = 15,
  Bahamas = 16, Bahrain = 17, Bangladesh = 18, Barbados = 19,
  Belarus = 20, Belgium = 21, Belize = 22, Benin = 23,
  Bermuda = 24, Bhutan = 25, Bolivia = 26, BosniaAndHerzegowina = 27,
  Botswana = 28, BouvetIsland = 29, Brazil = 30, BritishIndianOceanTerritory = 31,
  BruneiDarussalam = 32, Bulgaria = 33, BurkinaFaso = 34, Burundi = 35,
  Cambodia = 36, Cameroon = 37, Canada = 38, CapeVerde = 39,
  CaymanIslands = 40, CentralAfricanRepublic = 41, Chad = 42, Chile = 43,
  China = 44, ChristmasIsland = 45, CocosIslands = 46, Colombia = 47,
  Comoros = 48, DemocraticRepublicOfCongo = 49, PeoplesRepublicOfCongo = 50, CookIslands = 51,
  CostaRica = 52, IvoryCoast = 53, Croatia = 54, Cuba = 55,
  Cyprus = 56, CzechRepublic = 57, Denmark = 58, Djibouti = 59,
  Dominica = 60, DominicanRepublic = 61, EastTimor = 62, Ecuador = 63,
  Egypt = 64, ElSalvador = 65, EquatorialGuinea = 66, Eritrea = 67,
  Estonia = 68, Ethiopia = 69, FalklandIslands = 70, FaroeIslands = 71,
  FijiCountry = 72, Finland = 73, France = 74, MetropolitanFrance = 75,
  FrenchGuiana = 76, FrenchPolynesia = 77, FrenchSouthernTerritories = 78, Gabon = 79,
  Gambia = 80, Georgia = 81, Germany = 82, Ghana = 83,
  Gibraltar = 84, Greece = 85, Greenland = 86, Grenada = 87,
  Guadeloupe = 88, Guam = 89, Guatemala = 90, Guinea = 91,
  GuineaBissau = 92, Guyana = 93, Haiti = 94, HeardAndMcDonaldIslands = 95,
  Honduras = 96, HongKong = 97, Hungary = 98, Iceland = 99,
  India = 100, Indonesia = 101, Iran = 102, Iraq = 103,
  Ireland = 104, Israel = 105, Italy = 106, Jamaica = 107,
  Japan = 108, Jordan = 109, Kazakhstan = 110, Kenya = 111,
  Kiribati = 112, DemocraticRepublicOfKorea = 113, RepublicOfKorea = 114, Kuwait = 115,
  Kyrgyzstan = 116, Lao = 117, Latvia = 118, Lebanon = 119,
  Lesotho = 120, Liberia = 121, LibyanArabJamahiriya = 122, Liechtenstein = 123,
  Lithuania = 124, Luxembourg = 125, Macau = 126, Macedonia = 127,
  Madagascar = 128, Malawi = 129, Malaysia = 130, Maldives = 131,
  Mali = 132, Malta = 133, MarshallIslands = 134, Martinique = 135,
  Mauritania = 136, Mauritius = 137, Mayotte = 138, Mexico = 139,
  Micronesia = 140, Moldova = 141, Monaco = 142, Mongolia = 143,
  Montserrat = 144, Morocco = 145, Mozambique = 146, Myanmar = 147,
  Namibia = 148, NauruCountry = 149, Nepal = 150, Netherlands = 151,
  NetherlandsAntilles = 152, NewCaledonia = 153, NewZealand = 154, Nicaragua = 155,
  Niger = 156, Nigeria = 157, Niue = 158, NorfolkIsland = 159,
  NorthernMarianaIslands = 160, Norway = 161, Oman = 162, Pakistan = 163,
  Palau = 164, PalestinianTerritory = 165, Panama = 166, PapuaNewGuinea = 167,
  Paraguay = 168, Peru = 169, Philippines = 170, Pitcairn = 171,
  Poland = 172, Portugal = 173, PuertoRico = 174, Qatar = 175,
  Reunion = 176, Romania = 177, RussianFederation = 178, Rwanda = 179,
  SaintKittsAndNevis = 180, StLucia = 181, StVincentAndTheGrenadines = 182, Samoa = 183,
  SanMarino = 184, SaoTomeAndPrincipe = 185, SaudiArabia = 186, Senegal = 187,
  Seychelles = 188, SierraLeone = 189, Singapore = 190, Slovakia = 191,
  Slovenia = 192, SolomonIslands = 193, Somalia = 194, SouthAfrica = 195,
  SouthGeorgiaAndTheSouthSandwichIslands = 196, Spain = 197, SriLanka = 198, StHelena = 199,
  StPierreAndMiquelon = 200, Sudan = 201, Suriname = 202, SvalbardAndJanMayenIslands = 203,
  Swaziland = 204, Sweden = 205, Switzerland = 206, SyrianArabRepublic = 207,
  Taiwan = 208, Tajikistan = 209, Tanzania = 210, Thailand = 211,
  Togo = 212, Tokelau = 213, TongaCountry = 214, TrinidadAndTobago = 215,
  Tunisia = 216, Turkey = 217, Turkmenistan = 218, TurksAndCaicosIslands = 219,
  Tuvalu = 220, Uganda = 221, Ukraine = 222, UnitedArabEmirates = 223,
  UnitedKingdom = 224, UnitedStates = 225, UnitedStatesMinorOutlyingIslands = 226, Uruguay = 227,
  Uzbekistan = 228, Vanuatu = 229, VaticanCityState = 230, Venezuela = 231,
  VietNam = 232, BritishVirginIslands = 233, USVirginIslands = 234, WallisAndFutunaIslands = 235,
  WesternSahara = 236, Yemen = 237, Yugoslavia = 238, Zambia = 239,
  Zimbabwe = 240, SerbiaAndMontenegro = 241, Montenegro = 242, Serbia = 243,
  SaintBarthelemy = 244, SaintMartin = 245, LatinAmericaAndTheCaribbean = 246, LastCountry = LatinAmericaAndTheCaribbean
}
 
enum  CurrencySymbolFormat { CurrencyIsoCode, CurrencySymbol, CurrencyDisplayName }
 Specifies the format of the currency symbol. More...
 
enum  FormatType { LongFormat, ShortFormat, NarrowFormat }
 
enum  Language {
  AnyLanguage = 0, C = 1, Abkhazian = 2, Afan = 3,
  Afar = 4, Afrikaans = 5, Albanian = 6, Amharic = 7,
  Arabic = 8, Armenian = 9, Assamese = 10, Aymara = 11,
  Azerbaijani = 12, Bashkir = 13, Basque = 14, Bengali = 15,
  Bhutani = 16, Bihari = 17, Bislama = 18, Breton = 19,
  Bulgarian = 20, Burmese = 21, Byelorussian = 22, Cambodian = 23,
  Catalan = 24, Chinese = 25, Corsican = 26, Croatian = 27,
  Czech = 28, Danish = 29, Dutch = 30, English = 31,
  Esperanto = 32, Estonian = 33, Faroese = 34, FijiLanguage = 35,
  Finnish = 36, French = 37, Frisian = 38, Gaelic = 39,
  Galician = 40, Georgian = 41, German = 42, Greek = 43,
  Greenlandic = 44, Guarani = 45, Gujarati = 46, Hausa = 47,
  Hebrew = 48, Hindi = 49, Hungarian = 50, Icelandic = 51,
  Indonesian = 52, Interlingua = 53, Interlingue = 54, Inuktitut = 55,
  Inupiak = 56, Irish = 57, Italian = 58, Japanese = 59,
  Javanese = 60, Kannada = 61, Kashmiri = 62, Kazakh = 63,
  Kinyarwanda = 64, Kirghiz = 65, Korean = 66, Kurdish = 67,
  Rundi = 68, Laothian = 69, Latin = 70, Latvian = 71,
  Lingala = 72, Lithuanian = 73, Macedonian = 74, Malagasy = 75,
  Malay = 76, Malayalam = 77, Maltese = 78, Maori = 79,
  Marathi = 80, Moldavian = 81, Mongolian = 82, NauruLanguage = 83,
  Nepali = 84, Norwegian = 85, Occitan = 86, Oriya = 87,
  Pashto = 88, Persian = 89, Polish = 90, Portuguese = 91,
  Punjabi = 92, Quechua = 93, RhaetoRomance = 94, Romanian = 95,
  Russian = 96, Samoan = 97, Sangho = 98, Sanskrit = 99,
  Serbian = 100, SerboCroatian = 101, Sesotho = 102, Setswana = 103,
  Shona = 104, Sindhi = 105, Singhalese = 106, Siswati = 107,
  Slovak = 108, Slovenian = 109, Somali = 110, Spanish = 111,
  Sundanese = 112, Swahili = 113, Swedish = 114, Tagalog = 115,
  Tajik = 116, Tamil = 117, Tatar = 118, Telugu = 119,
  Thai = 120, Tibetan = 121, Tigrinya = 122, TongaLanguage = 123,
  Tsonga = 124, Turkish = 125, Turkmen = 126, Twi = 127,
  Uigur = 128, Ukrainian = 129, Urdu = 130, Uzbek = 131,
  Vietnamese = 132, Volapuk = 133, Welsh = 134, Wolof = 135,
  Xhosa = 136, Yiddish = 137, Yoruba = 138, Zhuang = 139,
  Zulu = 140, Nynorsk = 141, Bosnian = 142, Divehi = 143,
  Manx = 144, Cornish = 145, Akan = 146, Konkani = 147,
  Ga = 148, Igbo = 149, Kamba = 150, Syriac = 151,
  Blin = 152, Geez = 153, Koro = 154, Sidamo = 155,
  Atsam = 156, Tigre = 157, Jju = 158, Friulian = 159,
  Venda = 160, Ewe = 161, Walamo = 162, Hawaiian = 163,
  Tyap = 164, Chewa = 165, Filipino = 166, SwissGerman = 167,
  SichuanYi = 168, Kpelle = 169, LowGerman = 170, SouthNdebele = 171,
  NorthernSotho = 172, NorthernSami = 173, Taroko = 174, Gusii = 175,
  Taita = 176, Fulah = 177, Kikuyu = 178, Samburu = 179,
  Sena = 180, NorthNdebele = 181, Rombo = 182, Tachelhit = 183,
  Kabyle = 184, Nyankole = 185, Bena = 186, Vunjo = 187,
  Bambara = 188, Embu = 189, Cherokee = 190, Morisyen = 191,
  Makonde = 192, Langi = 193, Ganda = 194, Bemba = 195,
  Kabuverdianu = 196, Meru = 197, Kalenjin = 198, Nama = 199,
  Machame = 200, Colognian = 201, Masai = 202, Soga = 203,
  Luyia = 204, Asu = 205, Teso = 206, Saho = 207,
  KoyraChiini = 208, Rwa = 209, Luo = 210, Chiga = 211,
  CentralMoroccoTamazight = 212, KoyraboroSenni = 213, Shambala = 214, Bodo = 215,
  Aghem = 216, Basaa = 217, Zarma = 218, Duala = 219,
  JolaFonyi = 220, Ewondo = 221, Bafia = 222, LubaKatanga = 223,
  MakhuwaMeetto = 224, Mundang = 225, Kwasio = 226, Nuer = 227,
  Sakha = 228, Sangu = 229, CongoSwahili = 230, Tasawaq = 231,
  Vai = 232, Walser = 233, Yangben = 234, NorwegianBokmal = Norwegian,
  NorwegianNynorsk = Nynorsk, Kurundi = Rundi, LastLanguage = Yangben
}
 
enum  MeasurementSystem { MetricSystem, ImperialSystem }
 
enum  NumberOption { OmitGroupSeparator = 0x01, RejectGroupSeparator = 0x02 }
 
enum  QuotationStyle { StandardQuotation, AlternateQuotation }
 
enum  Script {
  AnyScript = 0, ArabicScript = 1, CyrillicScript = 2, DeseretScript = 3,
  GurmukhiScript = 4, SimplifiedHanScript = 5, TraditionalHanScript = 6, LatinScript = 7,
  MongolianScript = 8, TifinaghScript = 9, SimplifiedChineseScript = SimplifiedHanScript, TraditionalChineseScript = TraditionalHanScript,
  LastScript = TifinaghScript
}
 

Public Functions

QString amText () const
 Returns the localized name of the "AM" suffix for times specified using the conventions of the 12-hour clock. More...
 
QString bcp47Name () const
 Returns the dash-separated language, script and country (and possibly other BCP47 fields) of this locale as a string. More...
 
Country country () const
 Returns the country of this locale. More...
 
QString createSeparatedList (const QStringList &strl) const
 Returns a string that represents a join of a given list of strings with a separator defined by the locale. More...
 
QString currencySymbol (CurrencySymbolFormat=CurrencySymbol) const
 Returns a currency symbol according to the format. More...
 
QString dateFormat (FormatType format=LongFormat) const
 Returns the date format used for the current locale. More...
 
QString dateTimeFormat (FormatType format=LongFormat) const
 Returns the date time format used for the current locale. More...
 
QString dayName (int, FormatType format=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. More...
 
QChar decimalPoint () const
 Returns the decimal point character of this locale. More...
 
QChar exponential () const
 Returns the exponential character of this locale. More...
 
Qt::DayOfWeek firstDayOfWeek () const
 Returns the first day of the week according to the current locale. More...
 
QChar groupSeparator () const
 Returns the group separator character of this locale. More...
 
Language language () const
 Returns the language of this locale. More...
 
MeasurementSystem measurementSystem () const
 Returns the measurement system for the locale. More...
 
QString monthName (int, FormatType format=LongFormat) const
 Returns the localized name of month, in the format specified by type. More...
 
QString 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. More...
 
QString nativeCountryName () const
 Returns a native name of the country for the locale. More...
 
QString nativeLanguageName () const
 Returns a native name of the language for the locale. More...
 
QChar negativeSign () const
 Returns the negative sign character of this locale. More...
 
NumberOptions numberOptions () const
 Returns the options related to number conversions for this QLocale instance. More...
 
bool operator!= (const QLocale &other) const
 
QLocaleoperator= (const QLocale &other)
 Assigns other to this QLocale object and returns a reference to this QLocale object. More...
 
bool operator== (const QLocale &other) const
 
QChar percent () const
 Returns the percent character of this locale. More...
 
QString pmText () const
 Returns the localized name of the "PM" suffix for times specified using the conventions of the 12-hour clock. More...
 
QChar positiveSign () const
 Returns the positive sign character of this locale. More...
 
 QLocale ()
 Constructs a QLocale object initialized with the default locale. More...
 
 QLocale (const QString &name)
 Constructs a QLocale object with the specified name, which has the format "language[_script][_country][.codeset][@modifier]" or "C", where: More...
 
 QLocale (Language language, Country country=AnyCountry)
 Constructs a QLocale object with the specified language and country. More...
 
 QLocale (Language language, Script script, Country country)
 Constructs a QLocale object with the specified language, script and country. More...
 
 QLocale (const QLocale &other)
 Constructs a QLocale object as a copy of other. More...
 
QString quoteString (const QString &str, QuotationStyle style=StandardQuotation) const
 Returns str quoted according to the current locale using the given quotation style. More...
 
QString quoteString (const QStringRef &str, QuotationStyle style=StandardQuotation) const
 
Script script () const
 Returns the script of this locale. More...
 
void setNumberOptions (NumberOptions options)
 Sets the options related to number conversions for this QLocale instance. More...
 
QString standaloneDayName (int, FormatType format=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. More...
 
QString standaloneMonthName (int, FormatType format=LongFormat) const
 Returns the localized name of month that is used as a standalone text, in the format specified by type. More...
 
Qt::LayoutDirection textDirection () const
 Returns the text direction of the language. More...
 
QString timeFormat (FormatType format=LongFormat) const
 Returns the time format used for the current locale. More...
 
QString toCurrencyString (qlonglong, const QString &symbol=QString()) const
 Returns a localized string representation of value as a currency. More...
 
QString toCurrencyString (qulonglong, const QString &symbol=QString()) const
 
QString toCurrencyString (short, const QString &symbol=QString()) const
 
QString toCurrencyString (ushort, const QString &symbol=QString()) const
 
QString toCurrencyString (int, const QString &symbol=QString()) const
 
QString toCurrencyString (uint, const QString &symbol=QString()) const
 
QString toCurrencyString (double, const QString &symbol=QString()) const
 
QString toCurrencyString (float, const QString &symbol=QString()) const
 
QDate toDate (const QString &string, FormatType=LongFormat) const
 Parses the date string given in string and returns the date. More...
 
QDate toDate (const QString &string, const QString &format) const
 Parses the date string given in string and returns the date. More...
 
QDateTime toDateTime (const QString &string, FormatType format=LongFormat) const
 Parses the date/time string given in string and returns the time. More...
 
QDateTime toDateTime (const QString &string, const QString &format) const
 Parses the date/time string given in string and returns the time. More...
 
double toDouble (const QString &s, bool *ok=0) const
 Returns the double represented by the localized string s, or 0.0 if the conversion failed. More...
 
float toFloat (const QString &s, bool *ok=0) const
 
int toInt (const QString &s, bool *ok=0, int base=0) const
 Returns the int represented by the localized string s, using base base. More...
 
qlonglong toLongLong (const QString &s, bool *ok=0, int base=0) const
 Returns the long long int represented by the localized string s, using base base. More...
 
QString toLower (const QString &str) const
 Returns a lowercase copy of str. More...
 
short toShort (const QString &s, bool *ok=0, int base=0) const
 Returns the short int represented by the localized string s, using base base. More...
 
QString toString (qlonglong i) const
 Returns a localized string representation of i. More...
 
QString toString (qulonglong i) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.f and prec have the same meaning as in QString::number(double, char, int). More...
 
QString toString (float i, char f='g', int prec=6) const
 
QString toString (const QDate &date, const QString &formatStr) const
 Returns a localized string representation of the given date in the specified format. More...
 
QString toString (const QDate &date, FormatType format=LongFormat) const
 Returns a localized string representation of the given date according to the specified format. More...
 
QString toString (const QTime &time, const QString &formatStr) const
 Returns a localized string representation of the given time according to the specified format. More...
 
QString toString (const QTime &time, FormatType format=LongFormat) const
 Returns a localized string representation of the given time in the specified format. More...
 
QString toString (const QDateTime &dateTime, FormatType format=LongFormat) const
 Returns a localized string representation of the given dateTime according to the specified format. More...
 
QString toString (const QDateTime &dateTime, const QString &format) const
 Returns a localized string representation of the given dateTime according to the specified format. More...
 
QTime toTime (const QString &string, FormatType=LongFormat) const
 Parses the time string given in string and returns the time. More...
 
QTime toTime (const QString &string, const QString &format) const
 Parses the time string given in string and returns the time. More...
 
uint toUInt (const QString &s, bool *ok=0, int base=0) const
 Returns the unsigned int represented by the localized string s, using base base. More...
 
qlonglong toULongLong (const QString &s, bool *ok=0, int base=0) const
 Returns the unsigned long long int represented by the localized string s, using base base. More...
 
QString toUpper (const QString &str) const
 Returns an uppercase copy of str. More...
 
ushort toUShort (const QString &s, bool *ok=0, int base=0) const
 Returns the unsigned short int represented by the localized string s, using base base. More...
 
QStringList uiLanguages () const
 Returns an ordered list of locale names for translation purposes in preference order. More...
 
QList< Qt::DayOfWeekweekdays () const
 Returns a list of days that are considered weekdays according to the current locale. More...
 
QChar zeroDigit () const
 Returns the zero digit character of this locale. More...
 

Static Public Functions

static QLocale c ()
 Returns a QLocale object initialized to the "C" locale. More...
 
static QList< CountrycountriesForLanguage (Language lang)
 Returns the list of countries that have entires for language in Qt's locale database. More...
 
static QString countryToString (Country country)
 Returns a QString containing the name of country. More...
 
static QString languageToString (Language language)
 Returns a QString containing the name of language. More...
 
static QList< QLocalematchingLocales (QLocale::Language language, QLocale::Script script, QLocale::Country country)
 Returns a list of valid locale objects that match the given language, script and country. More...
 
static QString scriptToString (Script script)
 Returns a QString containing the name of script. More...
 
static void setDefault (const QLocale &locale)
 Sets the global default locale to locale. More...
 
static QLocale system ()
 Returns a QLocale object initialized to the system locale. More...
 

Private Functions

const QLocalePrivated () const
 

Properties

union {
   Data   p
 
   void *   v
 
}; 
 

Friends

class QByteArray
 
class QDoubleValidatorPrivate
 
class QIntValidator
 
struct QLocalePrivate
 
class QString
 
class QTextStream
 
class QTextStreamPrivate
 

Detailed Description

Definition at line 133 of file qlocale.h.

Enumerations

◆ Country

Enumerator
AnyCountry 
Afghanistan 
Albania 
Algeria 
AmericanSamoa 
Andorra 
Angola 
Anguilla 
Antarctica 
AntiguaAndBarbuda 
Argentina 
Armenia 
Aruba 
Australia 
Austria 
Azerbaijan 
Bahamas 
Bahrain 
Bangladesh 
Barbados 
Belarus 
Belgium 
Belize 
Benin 
Bermuda 
Bhutan 
Bolivia 
BosniaAndHerzegowina 
Botswana 
BouvetIsland 
Brazil 
BritishIndianOceanTerritory 
BruneiDarussalam 
Bulgaria 
BurkinaFaso 
Burundi 
Cambodia 
Cameroon 
Canada 
CapeVerde 
CaymanIslands 
CentralAfricanRepublic 
Chad 
Chile 
China 
ChristmasIsland 
CocosIslands 
Colombia 
Comoros 
DemocraticRepublicOfCongo 
PeoplesRepublicOfCongo 
CookIslands 
CostaRica 
IvoryCoast 
Croatia 
Cuba 
Cyprus 
CzechRepublic 
Denmark 
Djibouti 
Dominica 
DominicanRepublic 
EastTimor 
Ecuador 
Egypt 
ElSalvador 
EquatorialGuinea 
Eritrea 
Estonia 
Ethiopia 
FalklandIslands 
FaroeIslands 
FijiCountry 
Finland 
France 
MetropolitanFrance 
FrenchGuiana 
FrenchPolynesia 
FrenchSouthernTerritories 
Gabon 
Gambia 
Georgia 
Germany 
Ghana 
Gibraltar 
Greece 
Greenland 
Grenada 
Guadeloupe 
Guam 
Guatemala 
Guinea 
GuineaBissau 
Guyana 
Haiti 
HeardAndMcDonaldIslands 
Honduras 
HongKong 
Hungary 
Iceland 
India 
Indonesia 
Iran 
Iraq 
Ireland 
Israel 
Italy 
Jamaica 
Japan 
Jordan 
Kazakhstan 
Kenya 
Kiribati 
DemocraticRepublicOfKorea 
RepublicOfKorea 
Kuwait 
Kyrgyzstan 
Lao 
Latvia 
Lebanon 
Lesotho 
Liberia 
LibyanArabJamahiriya 
Liechtenstein 
Lithuania 
Luxembourg 
Macau 
Macedonia 
Madagascar 
Malawi 
Malaysia 
Maldives 
Mali 
Malta 
MarshallIslands 
Martinique 
Mauritania 
Mauritius 
Mayotte 
Mexico 
Micronesia 
Moldova 
Monaco 
Mongolia 
Montserrat 
Morocco 
Mozambique 
Myanmar 
Namibia 
NauruCountry 
Nepal 
Netherlands 
NetherlandsAntilles 
NewCaledonia 
NewZealand 
Nicaragua 
Niger 
Nigeria 
Niue 
NorfolkIsland 
NorthernMarianaIslands 
Norway 
Oman 
Pakistan 
Palau 
PalestinianTerritory 
Panama 
PapuaNewGuinea 
Paraguay 
Peru 
Philippines 
Pitcairn 
Poland 
Portugal 
PuertoRico 
Qatar 
Reunion 
Romania 
RussianFederation 
Rwanda 
SaintKittsAndNevis 
StLucia 
StVincentAndTheGrenadines 
Samoa 
SanMarino 
SaoTomeAndPrincipe 
SaudiArabia 
Senegal 
Seychelles 
SierraLeone 
Singapore 
Slovakia 
Slovenia 
SolomonIslands 
Somalia 
SouthAfrica 
SouthGeorgiaAndTheSouthSandwichIslands 
Spain 
SriLanka 
StHelena 
StPierreAndMiquelon 
Sudan 
Suriname 
SvalbardAndJanMayenIslands 
Swaziland 
Sweden 
Switzerland 
SyrianArabRepublic 
Taiwan 
Tajikistan 
Tanzania 
Thailand 
Togo 
Tokelau 
TongaCountry 
TrinidadAndTobago 
Tunisia 
Turkey 
Turkmenistan 
TurksAndCaicosIslands 
Tuvalu 
Uganda 
Ukraine 
UnitedArabEmirates 
UnitedKingdom 
UnitedStates 
UnitedStatesMinorOutlyingIslands 
Uruguay 
Uzbekistan 
Vanuatu 
VaticanCityState 
Venezuela 
VietNam 
BritishVirginIslands 
USVirginIslands 
WallisAndFutunaIslands 
WesternSahara 
Yemen 
Yugoslavia 
Zambia 
Zimbabwe 
SerbiaAndMontenegro 
Montenegro 
Serbia 
SaintBarthelemy 
SaintMartin 
LatinAmericaAndTheCaribbean 
LastCountry 

Definition at line 405 of file qlocale.h.

405  {
406  AnyCountry = 0,
407  Afghanistan = 1,
408  Albania = 2,
409  Algeria = 3,
410  AmericanSamoa = 4,
411  Andorra = 5,
412  Angola = 6,
413  Anguilla = 7,
414  Antarctica = 8,
415  AntiguaAndBarbuda = 9,
416  Argentina = 10,
417  Armenia = 11,
418  Aruba = 12,
419  Australia = 13,
420  Austria = 14,
421  Azerbaijan = 15,
422  Bahamas = 16,
423  Bahrain = 17,
424  Bangladesh = 18,
425  Barbados = 19,
426  Belarus = 20,
427  Belgium = 21,
428  Belize = 22,
429  Benin = 23,
430  Bermuda = 24,
431  Bhutan = 25,
432  Bolivia = 26,
434  Botswana = 28,
435  BouvetIsland = 29,
436  Brazil = 30,
438  BruneiDarussalam = 32,
439  Bulgaria = 33,
440  BurkinaFaso = 34,
441  Burundi = 35,
442  Cambodia = 36,
443  Cameroon = 37,
444  Canada = 38,
445  CapeVerde = 39,
446  CaymanIslands = 40,
448  Chad = 42,
449  Chile = 43,
450  China = 44,
451  ChristmasIsland = 45,
452  CocosIslands = 46,
453  Colombia = 47,
454  Comoros = 48,
457  CookIslands = 51,
458  CostaRica = 52,
459  IvoryCoast = 53,
460  Croatia = 54,
461  Cuba = 55,
462  Cyprus = 56,
463  CzechRepublic = 57,
464  Denmark = 58,
465  Djibouti = 59,
466  Dominica = 60,
467  DominicanRepublic = 61,
468  EastTimor = 62,
469  Ecuador = 63,
470  Egypt = 64,
471  ElSalvador = 65,
472  EquatorialGuinea = 66,
473  Eritrea = 67,
474  Estonia = 68,
475  Ethiopia = 69,
476  FalklandIslands = 70,
477  FaroeIslands = 71,
478  FijiCountry = 72,
479  Finland = 73,
480  France = 74,
481  MetropolitanFrance = 75,
482  FrenchGuiana = 76,
483  FrenchPolynesia = 77,
485  Gabon = 79,
486  Gambia = 80,
487  Georgia = 81,
488  Germany = 82,
489  Ghana = 83,
490  Gibraltar = 84,
491  Greece = 85,
492  Greenland = 86,
493  Grenada = 87,
494  Guadeloupe = 88,
495  Guam = 89,
496  Guatemala = 90,
497  Guinea = 91,
498  GuineaBissau = 92,
499  Guyana = 93,
500  Haiti = 94,
502  Honduras = 96,
503  HongKong = 97,
504  Hungary = 98,
505  Iceland = 99,
506  India = 100,
507  Indonesia = 101,
508  Iran = 102,
509  Iraq = 103,
510  Ireland = 104,
511  Israel = 105,
512  Italy = 106,
513  Jamaica = 107,
514  Japan = 108,
515  Jordan = 109,
516  Kazakhstan = 110,
517  Kenya = 111,
518  Kiribati = 112,
520  RepublicOfKorea = 114,
521  Kuwait = 115,
522  Kyrgyzstan = 116,
523  Lao = 117,
524  Latvia = 118,
525  Lebanon = 119,
526  Lesotho = 120,
527  Liberia = 121,
528  LibyanArabJamahiriya = 122,
529  Liechtenstein = 123,
530  Lithuania = 124,
531  Luxembourg = 125,
532  Macau = 126,
533  Macedonia = 127,
534  Madagascar = 128,
535  Malawi = 129,
536  Malaysia = 130,
537  Maldives = 131,
538  Mali = 132,
539  Malta = 133,
540  MarshallIslands = 134,
541  Martinique = 135,
542  Mauritania = 136,
543  Mauritius = 137,
544  Mayotte = 138,
545  Mexico = 139,
546  Micronesia = 140,
547  Moldova = 141,
548  Monaco = 142,
549  Mongolia = 143,
550  Montserrat = 144,
551  Morocco = 145,
552  Mozambique = 146,
553  Myanmar = 147,
554  Namibia = 148,
555  NauruCountry = 149,
556  Nepal = 150,
557  Netherlands = 151,
558  NetherlandsAntilles = 152,
559  NewCaledonia = 153,
560  NewZealand = 154,
561  Nicaragua = 155,
562  Niger = 156,
563  Nigeria = 157,
564  Niue = 158,
565  NorfolkIsland = 159,
567  Norway = 161,
568  Oman = 162,
569  Pakistan = 163,
570  Palau = 164,
571  PalestinianTerritory = 165,
572  Panama = 166,
573  PapuaNewGuinea = 167,
574  Paraguay = 168,
575  Peru = 169,
576  Philippines = 170,
577  Pitcairn = 171,
578  Poland = 172,
579  Portugal = 173,
580  PuertoRico = 174,
581  Qatar = 175,
582  Reunion = 176,
583  Romania = 177,
584  RussianFederation = 178,
585  Rwanda = 179,
586  SaintKittsAndNevis = 180,
587  StLucia = 181,
589  Samoa = 183,
590  SanMarino = 184,
591  SaoTomeAndPrincipe = 185,
592  SaudiArabia = 186,
593  Senegal = 187,
594  Seychelles = 188,
595  SierraLeone = 189,
596  Singapore = 190,
597  Slovakia = 191,
598  Slovenia = 192,
599  SolomonIslands = 193,
600  Somalia = 194,
601  SouthAfrica = 195,
603  Spain = 197,
604  SriLanka = 198,
605  StHelena = 199,
606  StPierreAndMiquelon = 200,
607  Sudan = 201,
608  Suriname = 202,
610  Swaziland = 204,
611  Sweden = 205,
612  Switzerland = 206,
613  SyrianArabRepublic = 207,
614  Taiwan = 208,
615  Tajikistan = 209,
616  Tanzania = 210,
617  Thailand = 211,
618  Togo = 212,
619  Tokelau = 213,
620  TongaCountry = 214,
621  TrinidadAndTobago = 215,
622  Tunisia = 216,
623  Turkey = 217,
624  Turkmenistan = 218,
625  TurksAndCaicosIslands = 219,
626  Tuvalu = 220,
627  Uganda = 221,
628  Ukraine = 222,
629  UnitedArabEmirates = 223,
630  UnitedKingdom = 224,
631  UnitedStates = 225,
633  Uruguay = 227,
634  Uzbekistan = 228,
635  Vanuatu = 229,
636  VaticanCityState = 230,
637  Venezuela = 231,
638  VietNam = 232,
639  BritishVirginIslands = 233,
640  USVirginIslands = 234,
642  WesternSahara = 236,
643  Yemen = 237,
644  Yugoslavia = 238,
645  Zambia = 239,
646  Zimbabwe = 240,
647  SerbiaAndMontenegro = 241,
648  Montenegro = 242,
649  Serbia = 243,
650  SaintBarthelemy = 244,
651  SaintMartin = 245,
654  };

◆ CurrencySymbolFormat

Specifies the format of the currency symbol.

Since
4.8
  • CurrencyIsoCode a ISO-4217 code of the currency.
  • CurrencySymbol a currency symbol.
  • CurrencyDisplayName a user readable name of the currency.
Enumerator
CurrencyIsoCode 
CurrencySymbol 
CurrencyDisplayName 

Definition at line 666 of file qlocale.h.

◆ FormatType

Enumerator
LongFormat 
ShortFormat 
NarrowFormat 

Definition at line 659 of file qlocale.h.

◆ Language

Enumerator
AnyLanguage 
Abkhazian 
Afan 
Afar 
Afrikaans 
Albanian 
Amharic 
Arabic 
Armenian 
Assamese 
Aymara 
Azerbaijani 
Bashkir 
Basque 
Bengali 
Bhutani 
Bihari 
Bislama 
Breton 
Bulgarian 
Burmese 
Byelorussian 
Cambodian 
Catalan 
Chinese 
Corsican 
Croatian 
Czech 
Danish 
Dutch 
English 
Esperanto 
Estonian 
Faroese 
FijiLanguage 
Finnish 
French 
Frisian 
Gaelic 
Galician 
Georgian 
German 
Greek 
Greenlandic 
Guarani 
Gujarati 
Hausa 
Hebrew 
Hindi 
Hungarian 
Icelandic 
Indonesian 
Interlingua 
Interlingue 
Inuktitut 
Inupiak 
Irish 
Italian 
Japanese 
Javanese 
Kannada 
Kashmiri 
Kazakh 
Kinyarwanda 
Kirghiz 
Korean 
Kurdish 
Rundi 
Laothian 
Latin 
Latvian 
Lingala 
Lithuanian 
Macedonian 
Malagasy 
Malay 
Malayalam 
Maltese 
Maori 
Marathi 
Moldavian 
Mongolian 
NauruLanguage 
Nepali 
Norwegian 
Occitan 
Oriya 
Pashto 
Persian 
Polish 
Portuguese 
Punjabi 
Quechua 
RhaetoRomance 
Romanian 
Russian 
Samoan 
Sangho 
Sanskrit 
Serbian 
SerboCroatian 
Sesotho 
Setswana 
Shona 
Sindhi 
Singhalese 
Siswati 
Slovak 
Slovenian 
Somali 
Spanish 
Sundanese 
Swahili 
Swedish 
Tagalog 
Tajik 
Tamil 
Tatar 
Telugu 
Thai 
Tibetan 
Tigrinya 
TongaLanguage 
Tsonga 
Turkish 
Turkmen 
Twi 
Uigur 
Ukrainian 
Urdu 
Uzbek 
Vietnamese 
Volapuk 
Welsh 
Wolof 
Xhosa 
Yiddish 
Yoruba 
Zhuang 
Zulu 
Nynorsk 
Bosnian 
Divehi 
Manx 
Cornish 
Akan 
Konkani 
Ga 
Igbo 
Kamba 
Syriac 
Blin 
Geez 
Koro 
Sidamo 
Atsam 
Tigre 
Jju 
Friulian 
Venda 
Ewe 
Walamo 
Hawaiian 
Tyap 
Chewa 
Filipino 
SwissGerman 
SichuanYi 
Kpelle 
LowGerman 
SouthNdebele 
NorthernSotho 
NorthernSami 
Taroko 
Gusii 
Taita 
Fulah 
Kikuyu 
Samburu 
Sena 
NorthNdebele 
Rombo 
Tachelhit 
Kabyle 
Nyankole 
Bena 
Vunjo 
Bambara 
Embu 
Cherokee 
Morisyen 
Makonde 
Langi 
Ganda 
Bemba 
Kabuverdianu 
Meru 
Kalenjin 
Nama 
Machame 
Colognian 
Masai 
Soga 
Luyia 
Asu 
Teso 
Saho 
KoyraChiini 
Rwa 
Luo 
Chiga 
CentralMoroccoTamazight 
KoyraboroSenni 
Shambala 
Bodo 
Aghem 
Basaa 
Zarma 
Duala 
JolaFonyi 
Ewondo 
Bafia 
LubaKatanga 
MakhuwaMeetto 
Mundang 
Kwasio 
Nuer 
Sakha 
Sangu 
CongoSwahili 
Tasawaq 
Vai 
Walser 
Yangben 
NorwegianBokmal 
NorwegianNynorsk 
Kurundi 
LastLanguage 

Definition at line 148 of file qlocale.h.

148  {
149  AnyLanguage = 0,
150  C = 1,
151  Abkhazian = 2,
152  Afan = 3,
153  Afar = 4,
154  Afrikaans = 5,
155  Albanian = 6,
156  Amharic = 7,
157  Arabic = 8,
158  Armenian = 9,
159  Assamese = 10,
160  Aymara = 11,
161  Azerbaijani = 12,
162  Bashkir = 13,
163  Basque = 14,
164  Bengali = 15,
165  Bhutani = 16,
166  Bihari = 17,
167  Bislama = 18,
168  Breton = 19,
169  Bulgarian = 20,
170  Burmese = 21,
171  Byelorussian = 22,
172  Cambodian = 23,
173  Catalan = 24,
174  Chinese = 25,
175  Corsican = 26,
176  Croatian = 27,
177  Czech = 28,
178  Danish = 29,
179  Dutch = 30,
180  English = 31,
181  Esperanto = 32,
182  Estonian = 33,
183  Faroese = 34,
184  FijiLanguage = 35,
185  Finnish = 36,
186  French = 37,
187  Frisian = 38,
188  Gaelic = 39,
189  Galician = 40,
190  Georgian = 41,
191  German = 42,
192  Greek = 43,
193  Greenlandic = 44,
194  Guarani = 45,
195  Gujarati = 46,
196  Hausa = 47,
197  Hebrew = 48,
198  Hindi = 49,
199  Hungarian = 50,
200  Icelandic = 51,
201  Indonesian = 52,
202  Interlingua = 53,
203  Interlingue = 54,
204  Inuktitut = 55,
205  Inupiak = 56,
206  Irish = 57,
207  Italian = 58,
208  Japanese = 59,
209  Javanese = 60,
210  Kannada = 61,
211  Kashmiri = 62,
212  Kazakh = 63,
213  Kinyarwanda = 64,
214  Kirghiz = 65,
215  Korean = 66,
216  Kurdish = 67,
217  Rundi = 68,
218  Laothian = 69,
219  Latin = 70,
220  Latvian = 71,
221  Lingala = 72,
222  Lithuanian = 73,
223  Macedonian = 74,
224  Malagasy = 75,
225  Malay = 76,
226  Malayalam = 77,
227  Maltese = 78,
228  Maori = 79,
229  Marathi = 80,
230  Moldavian = 81,
231  Mongolian = 82,
232  NauruLanguage = 83,
233  Nepali = 84,
234  Norwegian = 85,
235  Occitan = 86,
236  Oriya = 87,
237  Pashto = 88,
238  Persian = 89,
239  Polish = 90,
240  Portuguese = 91,
241  Punjabi = 92,
242  Quechua = 93,
243  RhaetoRomance = 94,
244  Romanian = 95,
245  Russian = 96,
246  Samoan = 97,
247  Sangho = 98,
248  Sanskrit = 99,
249  Serbian = 100,
250  SerboCroatian = 101,
251  Sesotho = 102,
252  Setswana = 103,
253  Shona = 104,
254  Sindhi = 105,
255  Singhalese = 106,
256  Siswati = 107,
257  Slovak = 108,
258  Slovenian = 109,
259  Somali = 110,
260  Spanish = 111,
261  Sundanese = 112,
262  Swahili = 113,
263  Swedish = 114,
264  Tagalog = 115,
265  Tajik = 116,
266  Tamil = 117,
267  Tatar = 118,
268  Telugu = 119,
269  Thai = 120,
270  Tibetan = 121,
271  Tigrinya = 122,
272  TongaLanguage = 123,
273  Tsonga = 124,
274  Turkish = 125,
275  Turkmen = 126,
276  Twi = 127,
277  Uigur = 128,
278  Ukrainian = 129,
279  Urdu = 130,
280  Uzbek = 131,
281  Vietnamese = 132,
282  Volapuk = 133,
283  Welsh = 134,
284  Wolof = 135,
285  Xhosa = 136,
286  Yiddish = 137,
287  Yoruba = 138,
288  Zhuang = 139,
289  Zulu = 140,
290  Nynorsk = 141,
291  Bosnian = 142,
292  Divehi = 143,
293  Manx = 144,
294  Cornish = 145,
295  Akan = 146,
296  Konkani = 147,
297  Ga = 148,
298  Igbo = 149,
299  Kamba = 150,
300  Syriac = 151,
301  Blin = 152,
302  Geez = 153,
303  Koro = 154,
304  Sidamo = 155,
305  Atsam = 156,
306  Tigre = 157,
307  Jju = 158,
308  Friulian = 159,
309  Venda = 160,
310  Ewe = 161,
311  Walamo = 162,
312  Hawaiian = 163,
313  Tyap = 164,
314  Chewa = 165,
315  Filipino = 166,
316  SwissGerman = 167,
317  SichuanYi = 168,
318  Kpelle = 169,
319  LowGerman = 170,
320  SouthNdebele = 171,
321  NorthernSotho = 172,
322  NorthernSami = 173,
323  Taroko = 174,
324  Gusii = 175,
325  Taita = 176,
326  Fulah = 177,
327  Kikuyu = 178,
328  Samburu = 179,
329  Sena = 180,
330  NorthNdebele = 181,
331  Rombo = 182,
332  Tachelhit = 183,
333  Kabyle = 184,
334  Nyankole = 185,
335  Bena = 186,
336  Vunjo = 187,
337  Bambara = 188,
338  Embu = 189,
339  Cherokee = 190,
340  Morisyen = 191,
341  Makonde = 192,
342  Langi = 193,
343  Ganda = 194,
344  Bemba = 195,
345  Kabuverdianu = 196,
346  Meru = 197,
347  Kalenjin = 198,
348  Nama = 199,
349  Machame = 200,
350  Colognian = 201,
351  Masai = 202,
352  Soga = 203,
353  Luyia = 204,
354  Asu = 205,
355  Teso = 206,
356  Saho = 207,
357  KoyraChiini = 208,
358  Rwa = 209,
359  Luo = 210,
360  Chiga = 211,
362  KoyraboroSenni = 213,
363  Shambala = 214,
364  Bodo = 215,
365  Aghem = 216,
366  Basaa = 217,
367  Zarma = 218,
368  Duala = 219,
369  JolaFonyi = 220,
370  Ewondo = 221,
371  Bafia = 222,
372  LubaKatanga = 223,
373  MakhuwaMeetto = 224,
374  Mundang = 225,
375  Kwasio = 226,
376  Nuer = 227,
377  Sakha = 228,
378  Sangu = 229,
379  CongoSwahili = 230,
380  Tasawaq = 231,
381  Vai = 232,
382  Walser = 233,
383  Yangben = 234,
386  Kurundi = Rundi,
388  };

◆ MeasurementSystem

Enumerator
MetricSystem 
ImperialSystem 

Definition at line 657 of file qlocale.h.

◆ NumberOption

Enumerator
OmitGroupSeparator 
RejectGroupSeparator 

Definition at line 660 of file qlocale.h.

◆ QuotationStyle

Enumerator
StandardQuotation 
AlternateQuotation 

Definition at line 782 of file qlocale.h.

◆ Script

Enumerator
AnyScript 
ArabicScript 
CyrillicScript 
DeseretScript 
GurmukhiScript 
SimplifiedHanScript 
TraditionalHanScript 
LatinScript 
MongolianScript 
TifinaghScript 
SimplifiedChineseScript 
TraditionalChineseScript 
LastScript 

Definition at line 390 of file qlocale.h.

Constructors and Destructors

◆ QLocale() [1/5]

QLocale::QLocale ( )

Constructs a QLocale object initialized with the default locale.

If no default locale was set using setDefaultLocale(), this locale will be the same as the one returned by system().

See also
setDefault()

Definition at line 669 of file qlocale.cpp.

670  : v(0)
671 {
674 }
quint16 index
Definition: qlocale.h:789
Data p
Definition: qlocale.h:803
static const QLocalePrivate * defaultPrivate()
Definition: qlocale.cpp:548
void * v
Definition: qlocale.h:802
static uint default_number_options
Definition: qlocale.cpp:431
static quint16 localePrivateIndex(const QLocalePrivate *p)
Definition: qlocale.cpp:611
quint16 numberOptions
Definition: qlocale.h:790

◆ QLocale() [2/5]

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,
  • script is a titlecase, four-letter, ISO 15924 script code,
  • country is an uppercase, two- or three-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 369 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()

Definition at line 654 of file qlocale.cpp.

655  : v(0)
656 {
657  p.numberOptions = 0;
659 }
quint16 index
Definition: qlocale.h:789
Data p
Definition: qlocale.h:803
static const QLocalePrivate * findLocale(const QString &name)
Definition: qlocale.cpp:377
void * v
Definition: qlocale.h:802
static quint16 localePrivateIndex(const QLocalePrivate *p)
Definition: qlocale.cpp:611
quint16 numberOptions
Definition: qlocale.h:790

◆ QLocale() [3/5]

QLocale::QLocale ( Language  language,
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() country()

Definition at line 695 of file qlocale.cpp.

696  : v(0)
697 {
699 
700  // If not found, should default to system
701  if (d->languageId() == QLocale::C && language != QLocale::C) {
704  } else {
705  p.numberOptions = 0;
707  }
708 }
quint16 index
Definition: qlocale.h:789
Language language() const
Returns the language of this locale.
Definition: qlocale.cpp:920
Data p
Definition: qlocale.h:803
static const QLocalePrivate * defaultPrivate()
Definition: qlocale.cpp:548
quint16 languageId() const
Definition: qlocale_p.h:80
void * v
Definition: qlocale.h:802
static const QLocalePrivate * findLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)
Definition: qlocale.cpp:241
static uint default_number_options
Definition: qlocale.cpp:431
static quint16 localePrivateIndex(const QLocalePrivate *p)
Definition: qlocale.cpp:611
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
Country country() const
Returns the country of this locale.
Definition: qlocale.cpp:945
quint16 numberOptions
Definition: qlocale.h:790

◆ QLocale() [4/5]

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

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

Since
4.8
  • 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().

See also
setDefault() language() script() country()

Definition at line 737 of file qlocale.cpp.

738  : v(0)
739 {
741 
742  // If not found, should default to system
743  if (d->languageId() == QLocale::C && language != QLocale::C) {
746  } else {
747  p.numberOptions = 0;
749  }
750 }
quint16 index
Definition: qlocale.h:789
Language language() const
Returns the language of this locale.
Definition: qlocale.cpp:920
Data p
Definition: qlocale.h:803
static const QLocalePrivate * defaultPrivate()
Definition: qlocale.cpp:548
quint16 languageId() const
Definition: qlocale_p.h:80
void * v
Definition: qlocale.h:802
static const QLocalePrivate * findLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)
Definition: qlocale.cpp:241
static uint default_number_options
Definition: qlocale.cpp:431
static quint16 localePrivateIndex(const QLocalePrivate *p)
Definition: qlocale.cpp:611
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
Script script() const
Returns the script of this locale.
Definition: qlocale.cpp:935
Country country() const
Returns the country of this locale.
Definition: qlocale.cpp:945
quint16 numberOptions
Definition: qlocale.h:790

◆ QLocale() [5/5]

QLocale::QLocale ( const QLocale other)

Constructs a QLocale object as a copy of other.

Definition at line 756 of file qlocale.cpp.

757 {
758  v = other.v;
759 }
void * v
Definition: qlocale.h:802

Functions

◆ amText()

QString QLocale::amText ( ) const

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

Since
4.5
See also
pmText()

Definition at line 2353 of file qlocale.cpp.

Referenced by QLocalePrivate::dateTimeToString(), and QSystemLocale::query().

2354 {
2355 #ifndef QT_NO_SYSTEMLOCALE
2356  if (d() == systemPrivate()) {
2358  if (!res.isNull())
2359  return res.toString();
2360  }
2361 #endif
2362  return getLocaleData(am_data + d()->m_am_idx, d()->m_am_size);
2363 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
static const ushort am_data[]
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const

◆ bcp47Name()

QString QLocale::bcp47Name ( ) const

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

Since
4.8

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.

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

Definition at line 1012 of file qlocale.cpp.

Referenced by qt_u_strToCase(), setDefault(), and uiLanguages().

1013 {
1014  return d()->bcp47Name();
1015 }
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString bcp47Name() const
Definition: qlocale.cpp:206

◆ c()

QLocale QLocale::c ( )
inlinestatic

◆ countriesForLanguage()

QList< QLocale::Country > QLocale::countriesForLanguage ( Language  language)
static

Returns the list of countries that have entires for language in Qt's locale database.

Since
4.3

If the result is an empty list, then language is not represented in Qt's locale database.

See also
matchingLocales()

Definition at line 1974 of file qlocale.cpp.

1975 {
1976  QList<Country> result;
1977 
1978  unsigned language_id = language;
1979  uint idx = locale_index[language_id];
1980 
1981  if (language == C) {
1982  result << AnyCountry;
1983  return result;
1984  }
1985 
1986  const QLocalePrivate *d = locale_data + idx;
1987 
1988  while (d->languageId() == language_id) {
1989  result << static_cast<Country>(d->countryId());
1990  ++d;
1991  }
1992 
1993  return result;
1994 }
Language language() const
Returns the language of this locale.
Definition: qlocale.cpp:920
quint16 countryId() const
Definition: qlocale_p.h:81
quint16 languageId() const
Definition: qlocale_p.h:80
unsigned int uint
Definition: qglobal.h:996
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static const QLocalePrivate locale_data[]
static const quint16 locale_index[]
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ country()

QLocale::Country QLocale::country ( ) const

Returns the country of this locale.

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

Definition at line 945 of file qlocale.cpp.

Referenced by QResourceRoot::findNode(), and QSystemLocale::query().

946 {
947  return Country(d()->countryId());
948 }
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ countryToString()

QString QLocale::countryToString ( Country  country)
static

Returns a QString containing the name of country.

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

Definition at line 1036 of file qlocale.cpp.

1037 {
1039  return QLatin1String("Unknown");
1041 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
unsigned int uint
Definition: qglobal.h:996
static const quint16 country_name_index[]
static const char country_name_list[]
Country country() const
Returns the country of this locale.
Definition: qlocale.cpp:945

◆ createSeparatedList()

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.

Since
4.8

Definition at line 855 of file qlocale.cpp.

856 {
857 #ifndef QT_NO_SYSTEMLOCALE
858  if (d() == systemPrivate()) {
859  QVariant res;
861 
862  if (!res.isNull())
863  return res.toString();
864  }
865 #endif
866 
867  const int size = list.size();
868  if (size == 1) {
869  return list.at(0);
870  } else if (size == 2) {
871  QString format = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_two_idx, d()->m_list_pattern_part_two_size);
872  return format.arg(list.at(0), list.at(1));
873  } else if (size > 2) {
874  QString formatStart = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_start_idx, d()->m_list_pattern_part_start_size);
875  QString formatMid = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_mid_idx, d()->m_list_pattern_part_mid_size);
876  QString formatEnd = getLocaleData(list_pattern_part_data + d()->m_list_pattern_part_end_idx, d()->m_list_pattern_part_end_size);
877  QString result = formatStart.arg(list.at(0), list.at(1));
878  for (int i = 2; i < size - 1; ++i)
879  result = formatMid.arg(result, list.at(i));
880  result = formatEnd.arg(result, list.at(size - 1));
881  return result;
882  }
883 
884  return QString();
885 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static const ushort list_pattern_part_data[]
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138

◆ currencySymbol()

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

Returns a currency symbol according to the format.

Since
4.8

Definition at line 3267 of file qlocale.cpp.

Referenced by toCurrencyString().

3268 {
3269 #ifndef QT_NO_SYSTEMLOCALE
3270  if (d() == systemPrivate()) {
3272  if (!res.isNull())
3273  return res.toString();
3274  }
3275 #endif
3276  quint32 idx, size;
3277  switch (format) {
3278  case CurrencySymbol:
3279  idx = d()->m_currency_symbol_idx;
3280  size = d()->m_currency_symbol_size;
3281  return getLocaleData(currency_symbol_data + idx, size);
3282  case CurrencyDisplayName:
3283  idx = d()->m_currency_display_name_idx;
3284  size = d()->m_currency_display_name_size;
3285  return getLocaleListData(currency_display_name_data + idx, size, 0);
3286  case CurrencyIsoCode: {
3287  int len = 0;
3288  const QLocalePrivate *d = this->d();
3289  for (; len < 3; ++len)
3290  if (!d->m_currency_iso_code[len])
3291  break;
3292  return len ? QString::fromLatin1(d->m_currency_iso_code, len) : QString();
3293  }
3294  }
3295  return QString();
3296 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static const ushort currency_symbol_data[]
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const ushort currency_display_name_data[]
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
static QString getLocaleListData(const ushort *data, int size, int index)
Definition: qlocale.cpp:555
quint16 m_currency_symbol_idx
Definition: qlocale_p.h:210
quint16 m_currency_symbol_size
Definition: qlocale_p.h:210
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138
quint16 m_currency_display_name_idx
Definition: qlocale_p.h:211
char m_currency_iso_code[3]
Definition: qlocale_p.h:209
quint16 m_currency_display_name_size
Definition: qlocale_p.h:211

◆ d()

const QLocalePrivate * QLocale::d ( ) const
private

◆ dateFormat()

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

Returns the date format used for the current locale.

Since
4.1

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

See also
QDate::toString(), QDate::fromString()

Definition at line 1495 of file qlocale.cpp.

Referenced by dateTimeFormat(), QSystemLocale::query(), QDateTimeEditPrivate::readLocaleSettings(), toDate(), and toString().

1496 {
1497 #ifndef QT_NO_SYSTEMLOCALE
1498  if (d() == systemPrivate()) {
1501  QVariant());
1502  if (!res.isNull())
1503  return res.toString();
1504  }
1505 #endif
1506 
1507  quint32 idx, size;
1508  switch (format) {
1509  case LongFormat:
1510  idx = d()->m_long_date_format_idx;
1511  size = d()->m_long_date_format_size;
1512  break;
1513  default:
1514  idx = d()->m_short_date_format_idx;
1515  size = d()->m_short_date_format_size;
1516  break;
1517  }
1518  return getLocaleData(date_format_data + idx, size);
1519 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
quint16 m_short_date_format_size
Definition: qlocale_p.h:191
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 m_long_date_format_idx
Definition: qlocale_p.h:192
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
quint16 m_short_date_format_idx
Definition: qlocale_p.h:191
quint16 m_long_date_format_size
Definition: qlocale_p.h:192
static const ushort date_format_data[]

◆ dateTimeFormat()

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

Returns the date time format used for the current locale.

Since
4.4

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

See also
QDateTime::toString(), QDateTime::fromString()

Definition at line 1575 of file qlocale.cpp.

Referenced by QDateTimeEditPrivate::readLocaleSettings(), toDateTime(), and toString().

1576 {
1577 #ifndef QT_NO_SYSTEMLOCALE
1578  if (d() == systemPrivate()) {
1582  QVariant());
1583  if (!res.isNull()) {
1584  return res.toString();
1585  }
1586  }
1587 #endif
1588  return dateFormat(format) + QLatin1Char(' ') + timeFormat(format);
1589 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
QString timeFormat(FormatType format=LongFormat) const
Returns the time format used for the current locale.
Definition: qlocale.cpp:1535
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
QString dateFormat(FormatType format=LongFormat) const
Returns the date format used for the current locale.
Definition: qlocale.cpp:1495
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ dayName()

QString QLocale::dayName ( int  day,
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.

Since
4.2
See also
monthName(), standaloneDayName()

Definition at line 2106 of file qlocale.cpp.

Referenced by QLocalePrivate::dateTimeToString(), QCalendarModel::dayName(), QDateTimeParser::findDay(), QDate::longDayName(), QSystemLocale::query(), QDateTimeParser::sectionMaxSize(), QDate::shortDayName(), standaloneDayName(), and QCalendarDayValidator::text().

2107 {
2108  if (day < 1 || day > 7)
2109  return QString();
2110 
2111 #ifndef QT_NO_SYSTEMLOCALE
2112  if (d() == systemPrivate()) {
2115  day);
2116  if (!res.isNull())
2117  return res.toString();
2118  }
2119 #endif
2120  if (day == 7)
2121  day = 0;
2122 
2123  quint32 idx, size;
2124  switch (type) {
2125  case QLocale::LongFormat:
2126  idx = d()->m_long_day_names_idx;
2127  size = d()->m_long_day_names_size;
2128  break;
2129  case QLocale::ShortFormat:
2130  idx = d()->m_short_day_names_idx;
2131  size = d()->m_short_day_names_size;
2132  break;
2133  case QLocale::NarrowFormat:
2134  idx = d()->m_narrow_day_names_idx;
2135  size = d()->m_narrow_day_names_size;
2136  break;
2137  default:
2138  return QString();
2139  }
2140  return getLocaleListData(days_data + idx, size, day);
2141 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
quint16 m_short_day_names_idx
Definition: qlocale_p.h:204
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
quint16 m_short_day_names_size
Definition: qlocale_p.h:204
static QString getLocaleListData(const ushort *data, int size, int index)
Definition: qlocale.cpp:555
quint16 m_narrow_day_names_size
Definition: qlocale_p.h:206
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 m_narrow_day_names_idx
Definition: qlocale_p.h:206
quint16 m_long_day_names_idx
Definition: qlocale_p.h:205
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138
static const ushort days_data[]
quint16 m_long_day_names_size
Definition: qlocale_p.h:205

◆ decimalPoint()

QChar QLocale::decimalPoint ( ) const

Returns the decimal point character of this locale.

Since
4.1

Definition at line 1765 of file qlocale.cpp.

Referenced by QTextStreamPrivate::getReal(), QSystemLocale::query(), and QDoubleSpinBoxPrivate::validateAndInterpret().

1766 {
1767  return d()->decimal();
1768 }
QChar decimal() const
Definition: qlocale_p.h:71
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ exponential()

QChar QLocale::exponential ( ) const

Returns the exponential character of this locale.

Since
4.1

Definition at line 1843 of file qlocale.cpp.

Referenced by QLocalePrivate::doubleToString(), and QTextStreamPrivate::getReal().

1844 {
1845  return d()->exponential();
1846 }
QChar exponential() const
Definition: qlocale_p.h:78
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ firstDayOfWeek()

Qt::DayOfWeek QLocale::firstDayOfWeek ( ) const

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

Since
4.8

Definition at line 2206 of file qlocale.cpp.

2207 {
2208 #ifndef QT_NO_SYSTEMLOCALE
2209  if (d() == systemPrivate()) {
2211  if (!res.isNull())
2212  return static_cast<Qt::DayOfWeek>(res.toUInt());
2213  }
2214 #endif
2215  return static_cast<Qt::DayOfWeek>(d()->m_first_day_of_week);
2216 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
DayOfWeek
Definition: qnamespace.h:1410
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
virtual QVariant query(QueryType type, QVariant in) const
quint16 m_first_day_of_week
Definition: qlocale_p.h:218

◆ groupSeparator()

QChar QLocale::groupSeparator ( ) const

Returns the group separator character of this locale.

Since
4.1

Definition at line 1778 of file qlocale.cpp.

Referenced by QTextStreamPrivate::getNumber(), QTextStreamPrivate::getReal(), QSystemLocale::query(), QSpinBoxPrivate::validateAndInterpret(), and QDoubleSpinBoxPrivate::validateAndInterpret().

1779 {
1780  return d()->group();
1781 }
QChar group() const
Definition: qlocale_p.h:72
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ language()

QLocale::Language QLocale::language ( ) const

Returns the language of this locale.

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

Definition at line 920 of file qlocale.cpp.

Referenced by countriesForLanguage(), QResourceRoot::findNode(), matchingLocales(), QSystemLocale::query(), and textDirection().

921 {
922  return Language(d()->languageId());
923 }
Language
Definition: qlocale.h:148
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ languageToString()

QString QLocale::languageToString ( Language  language)
static

Returns a QString containing the name of language.

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

Definition at line 1023 of file qlocale.cpp.

1024 {
1026  return QLatin1String("Unknown");
1028 }
Language language() const
Returns the language of this locale.
Definition: qlocale.cpp:920
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char language_name_list[]
unsigned int uint
Definition: qglobal.h:996
static const quint16 language_name_index[]

◆ matchingLocales()

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

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

Since
4.8

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

Definition at line 1937 of file qlocale.cpp.

1940 {
1943  return QList<QLocale>();
1944 
1945  QList<QLocale> result;
1946  const QLocalePrivate *d = locale_data;
1948  result.reserve(locale_data_size);
1949  if (language != QLocale::C)
1950  d += locale_index[language];
1951  while ( (d != locale_data + locale_data_size)
1953  QLocale locale(QLocale::C);
1954  locale.p.index = localePrivateIndex(d);
1955  result.append(locale);
1956  ++d;
1957  }
1958  return result;
1959 }
quint16 m_language_id
Definition: qlocale_p.h:180
Language language() const
Returns the language of this locale.
Definition: qlocale.cpp:920
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
unsigned int uint
Definition: qglobal.h:996
static quint16 localePrivateIndex(const QLocalePrivate *p)
Definition: qlocale.cpp:611
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
Script script() const
Returns the script of this locale.
Definition: qlocale.cpp:935
static const QLocalePrivate locale_data[]
Country country() const
Returns the country of this locale.
Definition: qlocale.cpp:945
static const quint16 locale_index[]
static const int locale_data_size
Definition: qlocale.cpp:596
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ measurementSystem()

QLocale::MeasurementSystem QLocale::measurementSystem ( ) const

Returns the measurement system for the locale.

Since
4.4

Definition at line 2265 of file qlocale.cpp.

Referenced by QPageSetupWidget::QPageSetupWidget(), and QPageSetupWidget::selectPrinter().

2266 {
2267 #ifndef QT_NO_SYSTEMLOCALE
2268  if (d() == systemPrivate()) {
2270  if (!res.isNull())
2271  return MeasurementSystem(res.toInt());
2272  }
2273 #endif
2274 
2275  return d()->measurementSystem();
2276 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
MeasurementSystem
Definition: qlocale.h:657
QLocale::MeasurementSystem measurementSystem() const
Definition: qlocale.cpp:2218

◆ monthName()

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

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

Since
4.2
See also
dayName(), standaloneMonthName()

Definition at line 2007 of file qlocale.cpp.

Referenced by QLocalePrivate::dateTimeToString(), QDateTimeParser::findMonth(), QDate::longMonthName(), QSystemLocale::query(), QDateTimeParser::sectionMaxSize(), QDate::shortMonthName(), and standaloneMonthName().

2008 {
2009  if (month < 1 || month > 12)
2010  return QString();
2011 
2012 #ifndef QT_NO_SYSTEMLOCALE
2013  if (d() == systemPrivate()) {
2016  month);
2017  if (!res.isNull())
2018  return res.toString();
2019  }
2020 #endif
2021 
2022  quint32 idx, size;
2023  switch (type) {
2024  case QLocale::LongFormat:
2025  idx = d()->m_long_month_names_idx;
2026  size = d()->m_long_month_names_size;
2027  break;
2028  case QLocale::ShortFormat:
2029  idx = d()->m_short_month_names_idx;
2030  size = d()->m_short_month_names_size;
2031  break;
2032  case QLocale::NarrowFormat:
2033  idx = d()->m_narrow_month_names_idx;
2034  size = d()->m_narrow_month_names_size;
2035  break;
2036  default:
2037  return QString();
2038  }
2039  return getLocaleListData(months_data + idx, size, month - 1);
2040 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
quint16 m_narrow_month_names_idx
Definition: qlocale_p.h:200
int type
Definition: qmetatype.cpp:239
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
quint16 m_short_month_names_size
Definition: qlocale_p.h:198
quint16 m_narrow_month_names_size
Definition: qlocale_p.h:200
static const ushort months_data[]
static QString getLocaleListData(const ushort *data, int size, int index)
Definition: qlocale.cpp:555
quint16 m_long_month_names_idx
Definition: qlocale_p.h:199
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138
quint16 m_long_month_names_size
Definition: qlocale_p.h:199
quint16 m_short_month_names_idx
Definition: qlocale_p.h:198

◆ name()

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(), bcp47Name()

Definition at line 963 of file qlocale.cpp.

Referenced by QTextCodec::canEncode(), QSvgSwitch::init(), operator<<(), QHttpNetworkConnectionPrivate::prepareRequest(), standaloneDayName(), and standaloneMonthName().

964 {
965  const QLocalePrivate *dd = d();
966 
968  return QString();
969  if (dd->m_language_id == QLocale::C)
970  return QLatin1String("C");
971 
972  const unsigned char *c = language_code_list + 3*(uint(dd->m_language_id));
973 
974  QString result(7, Qt::Uninitialized);
975  ushort *data = (ushort *)result.unicode();
976  const ushort *begin = data;
977 
978  *data++ = ushort(c[0]);
979  *data++ = ushort(c[1]);
980  if (c[2] != 0)
981  *data++ = ushort(c[2]);
982  if (dd->m_country_id != AnyCountry) {
983  *data++ = '_';
984  const unsigned char *c = country_code_list + 3*(uint(dd->m_country_id));
985  *data++ = ushort(c[0]);
986  *data++ = ushort(c[1]);
987  if (c[2] != 0)
988  *data++ = ushort(c[2]);
989  }
990  result.resize(data - begin);
991 
992  return result;
993 }
quint16 m_language_id
Definition: qlocale_p.h:180
quint16 m_country_id
Definition: qlocale_p.h:180
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const unsigned char country_code_list[]
static const unsigned char language_code_list[]
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
unsigned short ushort
Definition: qglobal.h:995
friend class QString
Definition: qlocale.h:138

◆ nativeCountryName()

QString QLocale::nativeCountryName ( ) const

Returns a native name of the country for the locale.

Since
4.8

For example "España" for Spanish/Spain locale.

See also
nativeLanguageName(), countryToString()

Definition at line 3459 of file qlocale.cpp.

3460 {
3461 #ifndef QT_NO_SYSTEMLOCALE
3462  if (d() == systemPrivate()) {
3464  if (!res.isNull())
3465  return res.toString();
3466  }
3467 #endif
3468  return getLocaleData(endonyms_data + d()->m_country_endonym_idx, d()->m_country_endonym_size);
3469 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static const ushort endonyms_data[]
virtual QVariant query(QueryType type, QVariant in) const

◆ nativeLanguageName()

QString QLocale::nativeLanguageName ( ) const

Returns a native name of the language for the locale.

Since
4.8

For example "Schwiizertüütsch" for Swiss-German locale.

See also
nativeCountryName(), languageToString()

Definition at line 3436 of file qlocale.cpp.

3437 {
3438 #ifndef QT_NO_SYSTEMLOCALE
3439  if (d() == systemPrivate()) {
3441  if (!res.isNull())
3442  return res.toString();
3443  }
3444 #endif
3445  return getLocaleData(endonyms_data + d()->m_language_endonym_idx, d()->m_language_endonym_size);
3446 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static const ushort endonyms_data[]
virtual QVariant query(QueryType type, QVariant in) const

◆ negativeSign()

QChar QLocale::negativeSign ( ) const

Returns the negative sign character of this locale.

Since
4.1

Definition at line 1817 of file qlocale.cpp.

Referenced by QTextStreamPrivate::getNumber(), QTextStreamPrivate::getReal(), QTextStreamPrivate::putNumber(), QTextStreamPrivate::putString(), and QSystemLocale::query().

1818 {
1819  return d()->minus();
1820 }
QChar minus() const
Definition: qlocale_p.h:77
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ numberOptions()

QLocale::NumberOptions QLocale::numberOptions ( ) const

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

Since
4.2

By default, no options are set for the standard locales.

Definition at line 802 of file qlocale.cpp.

Referenced by QString::arg(), operator!=(), operator==(), and setDefault().

803 {
804  return static_cast<NumberOption>(p.numberOptions);
805 }
Data p
Definition: qlocale.h:803
NumberOption
Definition: qlocale.h:660
quint16 numberOptions
Definition: qlocale.h:790

◆ operator!=()

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

Definition at line 822 of file qlocale.h.

823  { return d() != other.d() || numberOptions() != other.numberOptions(); }
NumberOptions numberOptions() const
Returns the options related to number conversions for this QLocale instance.
Definition: qlocale.cpp:802
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ operator=()

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

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

Definition at line 771 of file qlocale.cpp.

772 {
773  v = other.v;
774  return *this;
775 }
void * v
Definition: qlocale.h:802

◆ operator==()

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

Definition at line 820 of file qlocale.h.

821  { return d() == other.d() && numberOptions() == other.numberOptions(); }
NumberOptions numberOptions() const
Returns the options related to number conversions for this QLocale instance.
Definition: qlocale.cpp:802
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ percent()

QChar QLocale::percent ( ) const

Returns the percent character of this locale.

Since
4.1

Definition at line 1791 of file qlocale.cpp.

Referenced by QLocalePrivate::numberToCLocale().

1792 {
1793  return d()->percent();
1794 }
QChar percent() const
Definition: qlocale_p.h:74
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ pmText()

QString QLocale::pmText ( ) const

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

Since
4.5
See also
amText()

Definition at line 2376 of file qlocale.cpp.

Referenced by QLocalePrivate::dateTimeToString(), and QSystemLocale::query().

2377 {
2378 #ifndef QT_NO_SYSTEMLOCALE
2379  if (d() == systemPrivate()) {
2381  if (!res.isNull())
2382  return res.toString();
2383  }
2384 #endif
2385  return getLocaleData(pm_data + d()->m_pm_idx, d()->m_pm_size);
2386 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static const ushort pm_data[]
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const

◆ positiveSign()

QChar QLocale::positiveSign ( ) const

Returns the positive sign character of this locale.

Since
4.5

Definition at line 1830 of file qlocale.cpp.

Referenced by QTextStreamPrivate::getNumber(), QTextStreamPrivate::getReal(), QTextStreamPrivate::putString(), and QSystemLocale::query().

1831 {
1832  return d()->plus();
1833 }
QChar plus() const
Definition: qlocale_p.h:76
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ quoteString() [1/2]

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

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

Since
4.8

Definition at line 816 of file qlocale.cpp.

817 {
818  return quoteString(&str, style);
819 }
QString quoteString(const QString &str, QuotationStyle style=StandardQuotation) const
Returns str quoted according to the current locale using the given quotation style.
Definition: qlocale.cpp:816

◆ quoteString() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 826 of file qlocale.cpp.

827 {
828 #ifndef QT_NO_SYSTEMLOCALE
829  if (d() == systemPrivate()) {
830  QVariant res;
831  if (style == QLocale::AlternateQuotation)
833  if (res.isNull() || style == QLocale::StandardQuotation)
835  if (!res.isNull())
836  return res.toString();
837  }
838 #endif
839 
840  if (style == QLocale::StandardQuotation)
841  return QChar(d()->m_quotation_start) % str % QChar(d()->m_quotation_end);
842  else
843  return QChar(d()->m_alternate_quotation_start) % str % QChar(d()->m_alternate_quotation_end);
844 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const

◆ script()

QLocale::Script QLocale::script ( ) const

Returns the script of this locale.

Since
4.8
See also
language(), country(), languageToString(), scriptToString(), bcp47Name()

Definition at line 935 of file qlocale.cpp.

936 {
937  return Script(d()->m_script_id);
938 }
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ scriptToString()

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

Returns a QString containing the name of script.

Since
4.8
See also
languageToString(), countryToString(), script(), bcp47Name()

Definition at line 1053 of file qlocale.cpp.

1054 {
1056  return QLatin1String("Unknown");
1058 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
unsigned int uint
Definition: qglobal.h:996
static const char script_name_list[]
static const quint16 script_name_index[]
Script script() const
Returns the script of this locale.
Definition: qlocale.cpp:935

◆ setDefault()

void QLocale::setDefault ( const QLocale locale)
static

Sets the global default locale to locale.

Note
This class or function is not reentrant.

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.
See also
system() c()

Definition at line 905 of file qlocale.cpp.

906 {
907  default_lp = locale.d();
909 
910 #ifdef QT_USE_ICU
911  qt_initIcu(locale.bcp47Name());
912 #endif
913 }
NumberOptions numberOptions() const
Returns the options related to number conversions for this QLocale instance.
Definition: qlocale.cpp:802
static uint default_number_options
Definition: qlocale.cpp:431
bool qt_initIcu(const QString &localeString)
Definition: qlocale_icu.cpp:76
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static const QLocalePrivate * default_lp
Definition: qlocale.cpp:430
QString bcp47Name() const
Returns the dash-separated language, script and country (and possibly other BCP47 fields) of this loc...
Definition: qlocale.cpp:1012

◆ setNumberOptions()

void QLocale::setNumberOptions ( NumberOptions  options)

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

Since
4.2

Definition at line 786 of file qlocale.cpp.

Referenced by QAbstractItemViewPrivate::viewOptionsV4().

787 {
788  p.numberOptions = options;
789 }
Data p
Definition: qlocale.h:803
quint16 numberOptions
Definition: qlocale.h:790

◆ standaloneDayName()

QString QLocale::standaloneDayName ( int  day,
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.

Since
4.5

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

See also
dayName(), standaloneMonthName()

Definition at line 2158 of file qlocale.cpp.

Referenced by QCalendarModel::dayName(), QDate::longDayName(), and QDate::shortDayName().

2159 {
2160  if (day < 1 || day > 7)
2161  return QString();
2162 
2163 #ifndef QT_NO_SYSTEMLOCALE
2164  if (d() == systemPrivate()) {
2167  day);
2168  if (!res.isNull())
2169  return res.toString();
2170  }
2171 #endif
2172  if (day == 7)
2173  day = 0;
2174 
2175  quint32 idx, size;
2176  switch (type) {
2177  case QLocale::LongFormat:
2180  break;
2181  case QLocale::ShortFormat:
2184  break;
2185  case QLocale::NarrowFormat:
2188  break;
2189  default:
2190  return QString();
2191  }
2192  QString name = getLocaleListData(days_data + idx, size, day);
2193  if (name.isEmpty())
2194  return dayName(day == 0 ? 7 : day, type);
2195  return name;
2196 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
quint16 m_standalone_narrow_day_names_size
Definition: qlocale_p.h:203
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
quint16 m_standalone_narrow_day_names_idx
Definition: qlocale_p.h:203
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
quint16 m_standalone_long_day_names_idx
Definition: qlocale_p.h:202
QString 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.
Definition: qlocale.cpp:963
The QString class provides a Unicode character string.
Definition: qstring.h:83
quint16 m_standalone_short_day_names_size
Definition: qlocale_p.h:201
static QString getLocaleListData(const ushort *data, int size, int index)
Definition: qlocale.cpp:555
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
quint16 m_standalone_long_day_names_size
Definition: qlocale_p.h:202
quint16 m_standalone_short_day_names_idx
Definition: qlocale_p.h:201
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138
static const ushort days_data[]
QString dayName(int, FormatType format=LongFormat) const
Returns the localized name of the day (where 1 represents Monday, 2 represents Tuesday and so on)...
Definition: qlocale.cpp:2106

◆ standaloneMonthName()

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

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

Since
4.5

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

See also
monthName(), standaloneDayName()

Definition at line 2056 of file qlocale.cpp.

Referenced by QDate::longMonthName(), QCalendarWidget::minimumSizeHint(), QSystemLocale::query(), QDate::shortMonthName(), and QCalendarMonthValidator::text().

2057 {
2058  if (month < 1 || month > 12)
2059  return QString();
2060 
2061 #ifndef QT_NO_SYSTEMLOCALE
2062  if (d() == systemPrivate()) {
2065  month);
2066  if (!res.isNull())
2067  return res.toString();
2068  }
2069 #endif
2070 
2071  quint32 idx, size;
2072  switch (type) {
2073  case QLocale::LongFormat:
2076  break;
2077  case QLocale::ShortFormat:
2080  break;
2081  case QLocale::NarrowFormat:
2084  break;
2085  default:
2086  return QString();
2087  }
2088  QString name = getLocaleListData(standalone_months_data + idx, size, month - 1);
2089  if (name.isEmpty())
2090  return monthName(month, type);
2091  return name;
2092 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
quint16 m_standalone_long_month_names_idx
Definition: qlocale_p.h:196
quint16 m_standalone_long_month_names_size
Definition: qlocale_p.h:196
int type
Definition: qmetatype.cpp:239
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString monthName(int, FormatType format=LongFormat) const
Returns the localized name of month, in the format specified by type.
Definition: qlocale.cpp:2007
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
quint16 m_standalone_short_month_names_size
Definition: qlocale_p.h:195
QString 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.
Definition: qlocale.cpp:963
The QString class provides a Unicode character string.
Definition: qstring.h:83
quint16 m_standalone_narrow_month_names_size
Definition: qlocale_p.h:197
static QString getLocaleListData(const ushort *data, int size, int index)
Definition: qlocale.cpp:555
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
quint16 m_standalone_narrow_month_names_idx
Definition: qlocale_p.h:197
quint16 m_standalone_short_month_names_idx
Definition: qlocale_p.h:195
static const ushort standalone_months_data[]
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138

◆ system()

QLocale QLocale::system ( )
static

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()

Definition at line 1917 of file qlocale.cpp.

Referenced by QTextCodec::canEncode(), QDate::fromString(), QTime::fromString(), QDateTime::fromString(), QDate::longDayName(), QDate::longMonthName(), QHttpNetworkConnectionPrivate::prepareRequest(), QDateTimeParser::QDateTimeParser(), QPageSetupWidget::QPageSetupWidget(), QPageSetupWidget::selectPrinter(), QDate::shortDayName(), QDate::shortMonthName(), QDate::toString(), and QTime::toString().

1918 {
1919  QLocale result(C);
1920  result.p.index = localePrivateIndex(systemPrivate());
1921  return result;
1922 }
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
static quint16 localePrivateIndex(const QLocalePrivate *p)
Definition: qlocale.cpp:611

◆ textDirection()

Qt::LayoutDirection QLocale::textDirection ( ) const

Returns the text direction of the language.

Since
4.7

Definition at line 2286 of file qlocale.cpp.

Referenced by QXIMInputContext::QXIMInputContext().

2287 {
2288  Language lang = language();
2289  if (lang == QLocale::Arabic ||
2290  lang == QLocale::Hebrew ||
2291  lang == QLocale::Persian ||
2292  lang == QLocale::Urdu ||
2293  lang == QLocale::Syriac)
2294  return Qt::RightToLeft;
2295 
2296  return Qt::LeftToRight;
2297 }
Language language() const
Returns the language of this locale.
Definition: qlocale.cpp:920
Language
Definition: qlocale.h:148

◆ timeFormat()

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

Returns the time format used for the current locale.

Since
4.1

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

See also
QTime::toString(), QTime::fromString()

Definition at line 1535 of file qlocale.cpp.

Referenced by dateTimeFormat(), QDateTimeEditPrivate::readLocaleSettings(), toString(), and toTime().

1536 {
1537 #ifndef QT_NO_SYSTEMLOCALE
1538  if (d() == systemPrivate()) {
1541  QVariant());
1542  if (!res.isNull())
1543  return res.toString();
1544  }
1545 #endif
1546 
1547  quint32 idx, size;
1548  switch (format) {
1549  case LongFormat:
1550  idx = d()->m_long_time_format_idx;
1551  size = d()->m_long_time_format_size;
1552  break;
1553  default:
1554  idx = d()->m_short_time_format_idx;
1555  size = d()->m_short_time_format_size;
1556  break;
1557  }
1558  return getLocaleData(time_format_data + idx, size);
1559 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
quint16 m_long_time_format_idx
Definition: qlocale_p.h:194
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
quint16 m_long_time_format_size
Definition: qlocale_p.h:194
quint16 m_short_time_format_idx
Definition: qlocale_p.h:193
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
unsigned int quint32
Definition: qglobal.h:938
virtual QVariant query(QueryType type, QVariant in) const
static const ushort time_format_data[]
quint16 m_short_time_format_size
Definition: qlocale_p.h:193

◆ toCurrencyString() [1/8]

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

Returns a localized string representation of value as a currency.

Since
4.8

If the symbol is provided it is used instead of the default currency symbol.

See also
currencySymbol()

Definition at line 3309 of file qlocale.cpp.

3310 {
3311 #ifndef QT_NO_SYSTEMLOCALE
3312  if (d() == systemPrivate()) {
3313  QSystemLocale::CurrencyToStringArgument arg(value, symbol);
3315  if (!res.isNull())
3316  return res.toString();
3317  }
3318 #endif
3319  const QLocalePrivate *d = this->d();
3320  quint8 idx = d->m_currency_format_idx;
3321  quint8 size = d->m_currency_format_size;
3322  if (d->m_currency_negative_format_size && value < 0) {
3325  value = -value;
3326  }
3327  QString str = d->longLongToString(value);
3328  QString sym = symbol.isNull() ? currencySymbol() : symbol;
3329  if (sym.isEmpty())
3332  return format.arg(str, sym);
3333 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
unsigned char quint8
Definition: qglobal.h:934
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
static QString longLongToString(const QChar zero, const QChar group, const QChar plus, const QChar minus, qint64 l, int precision, int base, int width, unsigned flags)
Definition: qlocale.cpp:2775
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
quint8 m_currency_negative_format_size
Definition: qlocale_p.h:213
static const ushort currency_format_data[]
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
quint8 m_currency_negative_format_idx
Definition: qlocale_p.h:213
quint8 m_currency_format_idx
Definition: qlocale_p.h:212
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
virtual QVariant query(QueryType type, QVariant in) const
quint8 m_currency_format_size
Definition: qlocale_p.h:212
QString currencySymbol(CurrencySymbolFormat=CurrencySymbol) const
Returns a currency symbol according to the format.
Definition: qlocale.cpp:3267

◆ toCurrencyString() [2/8]

QString QLocale::toCurrencyString ( qulonglong  value,
const QString symbol = QString() 
) const
Since
4.8 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 3339 of file qlocale.cpp.

3340 {
3341 #ifndef QT_NO_SYSTEMLOCALE
3342  if (d() == systemPrivate()) {
3343  QSystemLocale::CurrencyToStringArgument arg(value, symbol);
3345  if (!res.isNull())
3346  return res.toString();
3347  }
3348 #endif
3349  const QLocalePrivate *d = this->d();
3350  quint8 idx = d->m_currency_format_idx;
3351  quint8 size = d->m_currency_format_size;
3352  QString str = d->unsLongLongToString(value);
3353  QString sym = symbol.isNull() ? currencySymbol() : symbol;
3354  if (sym.isEmpty())
3357  return format.arg(str, sym);
3358 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
unsigned char quint8
Definition: qglobal.h:934
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
static QString unsLongLongToString(const QChar zero, const QChar group, const QChar plus, quint64 l, int precision, int base, int width, unsigned flags)
Definition: qlocale.cpp:2870
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static const ushort currency_format_data[]
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
quint8 m_currency_format_idx
Definition: qlocale_p.h:212
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
virtual QVariant query(QueryType type, QVariant in) const
quint8 m_currency_format_size
Definition: qlocale_p.h:212
QString currencySymbol(CurrencySymbolFormat=CurrencySymbol) const
Returns a currency symbol according to the format.
Definition: qlocale.cpp:3267

◆ toCurrencyString() [3/8]

QString QLocale::toCurrencyString ( short  i,
const QString symbol = QString() 
) const
inline

Definition at line 825 of file qlocale.h.

826  { return toCurrencyString(qlonglong(i), symbol); }
QString toCurrencyString(qlonglong, const QString &symbol=QString()) const
Returns a localized string representation of value as a currency.
Definition: qlocale.cpp:3309
qint64 qlonglong
Definition: qglobal.h:951

◆ toCurrencyString() [4/8]

QString QLocale::toCurrencyString ( ushort  i,
const QString symbol = QString() 
) const
inline

Definition at line 827 of file qlocale.h.

828  { return toCurrencyString(qulonglong(i), symbol); }
QString toCurrencyString(qlonglong, const QString &symbol=QString()) const
Returns a localized string representation of value as a currency.
Definition: qlocale.cpp:3309
quint64 qulonglong
Definition: qglobal.h:952

◆ toCurrencyString() [5/8]

QString QLocale::toCurrencyString ( int  i,
const QString symbol = QString() 
) const
inline

Definition at line 829 of file qlocale.h.

830 { return toCurrencyString(qlonglong(i), symbol); }
QString toCurrencyString(qlonglong, const QString &symbol=QString()) const
Returns a localized string representation of value as a currency.
Definition: qlocale.cpp:3309
qint64 qlonglong
Definition: qglobal.h:951

◆ toCurrencyString() [6/8]

QString QLocale::toCurrencyString ( uint  i,
const QString symbol = QString() 
) const
inline

Definition at line 831 of file qlocale.h.

832 { return toCurrencyString(qulonglong(i), symbol); }
QString toCurrencyString(qlonglong, const QString &symbol=QString()) const
Returns a localized string representation of value as a currency.
Definition: qlocale.cpp:3309
quint64 qulonglong
Definition: qglobal.h:952

◆ toCurrencyString() [7/8]

QString QLocale::toCurrencyString ( double  value,
const QString symbol = QString() 
) const
Since
4.8 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 3364 of file qlocale.cpp.

3365 {
3366 #ifndef QT_NO_SYSTEMLOCALE
3367  if (d() == systemPrivate()) {
3368  QSystemLocale::CurrencyToStringArgument arg(value, symbol);
3370  if (!res.isNull())
3371  return res.toString();
3372  }
3373 #endif
3374  const QLocalePrivate *d = this->d();
3375  quint8 idx = d->m_currency_format_idx;
3376  quint8 size = d->m_currency_format_size;
3377  if (d->m_currency_negative_format_size && value < 0) {
3380  value = -value;
3381  }
3382  QString str = d->doubleToString(value, d->m_currency_digits,
3384  QString sym = symbol.isNull() ? currencySymbol() : symbol;
3385  if (sym.isEmpty())
3388  return format.arg(str, sym);
3389 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
unsigned char quint8
Definition: qglobal.h:934
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString doubleToString(const QChar zero, const QChar plus, const QChar minus, const QChar exponent, const QChar group, const QChar decimal, double d, int precision, DoubleForm form, int width, unsigned flags)
Definition: qlocale.cpp:2613
static QString getLocaleData(const ushort *data, int size)
Definition: qlocale.cpp:573
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
quint8 m_currency_negative_format_size
Definition: qlocale_p.h:213
static const ushort currency_format_data[]
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
quint8 m_currency_negative_format_idx
Definition: qlocale_p.h:213
quint8 m_currency_format_idx
Definition: qlocale_p.h:212
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
virtual QVariant query(QueryType type, QVariant in) const
quint8 m_currency_format_size
Definition: qlocale_p.h:212
QString currencySymbol(CurrencySymbolFormat=CurrencySymbol) const
Returns a currency symbol according to the format.
Definition: qlocale.cpp:3267
quint16 m_currency_digits
Definition: qlocale_p.h:216

◆ toCurrencyString() [8/8]

QString QLocale::toCurrencyString ( float  i,
const QString symbol = QString() 
) const
inline

Definition at line 833 of file qlocale.h.

834 { return toCurrencyString(double(i), symbol); }
QString toCurrencyString(qlonglong, const QString &symbol=QString()) const
Returns a localized string representation of value as a currency.
Definition: qlocale.cpp:3309

◆ toDate() [1/2]

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

Parses the date string given in string and returns the date.

Since
4.4

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.

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

Definition at line 1627 of file qlocale.cpp.

1628 {
1629  return toDate(string, dateFormat(format));
1630 }
QDate toDate(const QString &string, FormatType=LongFormat) const
Parses the date string given in string and returns the date.
Definition: qlocale.cpp:1627
QString dateFormat(FormatType format=LongFormat) const
Returns the date format used for the current locale.
Definition: qlocale.cpp:1495

◆ toDate() [2/2]

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

Parses the date string given in string and returns the date.

Since
4.4

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.

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

Definition at line 1704 of file qlocale.cpp.

1705 {
1706  QDate date;
1707 #ifndef QT_BOOTSTRAPPED
1709  dt.defaultLocale = *this;
1710  if (dt.parseFormat(format))
1711  dt.fromString(string, &date, 0);
1712 #else
1713  Q_UNUSED(string);
1714  Q_UNUSED(format);
1715 #endif
1716  return date;
1717 }
The QDate class provides date functions.
Definition: qdatetime.h:55
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ toDateTime() [1/2]

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

Parses the date/time string given in string and returns the time.

Since
4.4

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.

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

Definition at line 1649 of file qlocale.cpp.

Referenced by _q_parseDosDir(), _q_parseUnixDir(), and QNetworkHeadersPrivate::fromHttpDate().

1650 {
1651  return toDateTime(string, dateTimeFormat(format));
1652 }
QDateTime toDateTime(const QString &string, FormatType format=LongFormat) const
Parses the date/time string given in string and returns the time.
Definition: qlocale.cpp:1649
QString dateTimeFormat(FormatType format=LongFormat) const
Returns the date time format used for the current locale.
Definition: qlocale.cpp:1575

◆ toDateTime() [2/2]

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

Parses the date/time string given in string and returns the time.

Since
4.4

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.

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

Definition at line 1738 of file qlocale.cpp.

1739 {
1740 #ifndef QT_BOOTSTRAPPED
1741  QTime time;
1742  QDate date;
1743 
1745  dt.defaultLocale = *this;
1746  if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
1747  return QDateTime(date, time);
1748 #else
1749  Q_UNUSED(string);
1750  Q_UNUSED(format);
1751 #endif
1752  return QDateTime(QDate(), QTime(-1, -1, -1));
1753 }
The QDate class provides date functions.
Definition: qdatetime.h:55
The QTime class provides clock time functions.
Definition: qdatetime.h:148
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ toDouble()

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

Returns the double represented by the localized string s, or 0.0 if the conversion failed.

If ok is not 0, reports failure 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;
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
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(), toString()

Definition at line 1279 of file qlocale.cpp.

Referenced by QTextStreamPrivate::getReal(), toFloat(), and QDoubleSpinBoxPrivate::validateAndInterpret().

1280 {
1285 
1286  return d()->stringToDouble(s, ok, mode);
1287 }
Data p
Definition: qlocale.h:803
double stringToDouble(const QString &num, bool *ok, GroupSeparatorMode group_sep_mode) const
Definition: qlocale.cpp:3092
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 numberOptions
Definition: qlocale.h:790

◆ toFloat()

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

Definition at line 1244 of file qlocale.cpp.

1245 {
1246  bool myOk;
1247  double d = toDouble(s, &myOk);
1248  if (!myOk || d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) {
1249  if (ok != 0)
1250  *ok = false;
1251  return 0.0;
1252  }
1253  if (ok != 0)
1254  *ok = true;
1255  return float(d);
1256 }
#define QT_MAX_FLOAT
Returns the float represented by the localized string s, or 0.0 if the conversion failed...
Definition: qlocale.cpp:1242
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
double toDouble(const QString &s, bool *ok=0) const
Returns the double represented by the localized string s, or 0.0 if the conversion failed...
Definition: qlocale.cpp:1279

◆ toInt()

int QLocale::toInt ( const QString s,
bool *  ok = 0,
int  base = 0 
) const

Returns the int represented by the localized string s, using base base.

If base is 0 the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

If the conversion fails the function returns 0.

If ok is not 0, 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(), toString()

Definition at line 1133 of file qlocale.cpp.

Referenced by QIntValidator::validate(), and QSpinBoxPrivate::validateAndInterpret().

1134 {
1135  qlonglong i = toLongLong(s, ok, base);
1136  if (i < INT_MIN || i > INT_MAX) {
1137  if (ok != 0)
1138  *ok = false;
1139  return 0;
1140  }
1141  return int(i);
1142 }
static const uint base
Definition: qurl.cpp:268
qlonglong toLongLong(const QString &s, bool *ok=0, int base=0) const
Returns the long long int represented by the localized string s, using base base. ...
Definition: qlocale.cpp:1190
qint64 qlonglong
Definition: qglobal.h:951
#define INT_MAX

◆ toLongLong()

qlonglong QLocale::toLongLong ( const QString s,
bool *  ok = 0,
int  base = 0 
) const

Returns the long long int represented by the localized string s, using base base.

If base is 0 the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

If the conversion fails the function returns 0.

If ok is not 0, 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(), toString()

Definition at line 1190 of file qlocale.cpp.

Referenced by toInt(), and toShort().

1191 {
1196 
1197  return d()->stringToLongLong(s, base, ok, mode);
1198 }
qint64 stringToLongLong(const QString &num, int base, bool *ok, GroupSeparatorMode group_sep_mode) const
Definition: qlocale.cpp:3105
Data p
Definition: qlocale.h:803
static const uint base
Definition: qurl.cpp:268
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 numberOptions
Definition: qlocale.h:790

◆ toLower()

QString QLocale::toLower ( const QString str) const

Returns a lowercase copy of str.

Since
4.8

Definition at line 2328 of file qlocale.cpp.

2329 {
2330 #ifdef QT_USE_ICU
2331  {
2332  QString result;
2333  if (qt_u_strToLower(str, &result, *this))
2334  return result;
2335  // else fall through and use Qt's toUpper
2336  }
2337 #endif
2338  return str.toLower();
2339 }
bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389

◆ toShort()

short QLocale::toShort ( const QString s,
bool *  ok = 0,
int  base = 0 
) const

Returns the short int represented by the localized string s, using base base.

If base is 0 the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

If the conversion fails the function returns 0.

If ok is not 0, 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(), toString()

Definition at line 1077 of file qlocale.cpp.

1078 {
1079  qlonglong i = toLongLong(s, ok, base);
1080  if (i < SHRT_MIN || i > SHRT_MAX) {
1081  if (ok != 0)
1082  *ok = false;
1083  return 0;
1084  }
1085  return short(i);
1086 }
static const uint base
Definition: qurl.cpp:268
qlonglong toLongLong(const QString &s, bool *ok=0, int base=0) const
Returns the long long int represented by the localized string s, using base base. ...
Definition: qlocale.cpp:1190
qint64 qlonglong
Definition: qglobal.h:951

◆ toString() [1/14]

QString QLocale::toString ( qlonglong  i) const

Returns a localized string representation of i.

See also
toLongLong()

Definition at line 1295 of file qlocale.cpp.

Referenced by QStyledItemDelegate::displayText(), QIntValidator::fixup(), QSystemLocale::query(), QDateTimeEdit::textFromDateTime(), QSpinBox::textFromValue(), QDoubleSpinBox::textFromValue(), QNetworkHeadersPrivate::toHttpDate(), QNetworkCookie::toRawForm(), QDate::toString(), QTime::toString(), toString(), and QItemDelegatePrivate::valueToText().

1296 {
1297  int flags = p.numberOptions & OmitGroupSeparator
1298  ? 0
1300 
1301  return d()->longLongToString(i, -1, 10, -1, flags);
1302 }
Data p
Definition: qlocale.h:803
static QString longLongToString(const QChar zero, const QChar group, const QChar plus, const QChar minus, qint64 l, int precision, int base, int width, unsigned flags)
Definition: qlocale.cpp:2775
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 numberOptions
Definition: qlocale.h:790

◆ toString() [2/14]

QString QLocale::toString ( qulonglong  i) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
toULongLong()

Definition at line 1310 of file qlocale.cpp.

1311 {
1312  int flags = p.numberOptions & OmitGroupSeparator
1313  ? 0
1315 
1316  return d()->unsLongLongToString(i, -1, 10, -1, flags);
1317 }
Data p
Definition: qlocale.h:803
static QString unsLongLongToString(const QChar zero, const QChar group, const QChar plus, quint64 l, int precision, int base, int width, unsigned flags)
Definition: qlocale.cpp:2870
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 numberOptions
Definition: qlocale.h:790

◆ toString() [3/14]

QString QLocale::toString ( short  i) const
inline

Definition at line 810 of file qlocale.h.

811  { return toString(qlonglong(i)); }
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
qint64 qlonglong
Definition: qglobal.h:951

◆ toString() [4/14]

QString QLocale::toString ( ushort  i) const
inline

Definition at line 812 of file qlocale.h.

813  { return toString(qulonglong(i)); }
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
quint64 qulonglong
Definition: qglobal.h:952

◆ toString() [5/14]

QString QLocale::toString ( int  i) const
inline

Definition at line 814 of file qlocale.h.

815  { return toString(qlonglong(i)); }
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
qint64 qlonglong
Definition: qglobal.h:951

◆ toString() [6/14]

QString QLocale::toString ( uint  i) const
inline

Definition at line 816 of file qlocale.h.

817  { return toString(qulonglong(i)); }
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
quint64 qulonglong
Definition: qglobal.h:952

◆ toString() [7/14]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.f and prec have the same meaning as in QString::number(double, char, int).

See also
toDouble()

Definition at line 1869 of file qlocale.cpp.

1870 {
1872  uint flags = 0;
1873 
1874  if (qIsUpper(f))
1876  f = qToLower(f);
1877 
1878  switch (f) {
1879  case 'f':
1881  break;
1882  case 'e':
1884  break;
1885  case 'g':
1887  break;
1888  default:
1889  break;
1890  }
1891 
1894  return d()->doubleToString(i, prec, form, -1, flags);
1895 }
Data p
Definition: qlocale.h:803
static QString doubleToString(const QChar zero, const QChar plus, const QChar minus, const QChar exponent, const QChar group, const QChar decimal, double d, int precision, DoubleForm form, int width, unsigned flags)
Definition: qlocale.cpp:2613
unsigned int uint
Definition: qglobal.h:996
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
static char qToLower(char c)
Definition: qlocale.cpp:1853
quint16 numberOptions
Definition: qlocale.h:790
static bool qIsUpper(char c)
Definition: qlocale.cpp:1848

◆ toString() [8/14]

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

Definition at line 818 of file qlocale.h.

819  { return toString(double(i), f, prec); }
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295

◆ toString() [9/14]

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.

Definition at line 1325 of file qlocale.cpp.

1326 {
1327  return d()->dateTimeToString(format, &date, 0, this);
1328 }
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time, const QLocale *q) const
Definition: qlocale.cpp:2389

◆ toString() [10/14]

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

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

Definition at line 1335 of file qlocale.cpp.

1336 {
1337  if (!date.isValid())
1338  return QString();
1339 
1340 #ifndef QT_NO_SYSTEMLOCALE
1341  if (d() == systemPrivate()) {
1344  date);
1345  if (!res.isNull())
1346  return res.toString();
1347  }
1348 #endif
1349 
1350  QString format_str = dateFormat(format);
1351  return toString(date, format_str);
1352 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138
QString dateFormat(FormatType format=LongFormat) const
Returns the date format used for the current locale.
Definition: qlocale.cpp:1495

◆ toString() [11/14]

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.

Definition at line 1403 of file qlocale.cpp.

1404 {
1405  return d()->dateTimeToString(format, 0, &time, this);
1406 }
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time, const QLocale *q) const
Definition: qlocale.cpp:2389

◆ toString() [12/14]

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

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

Definition at line 1462 of file qlocale.cpp.

1463 {
1464  if (!time.isValid())
1465  return QString();
1466 
1467 #ifndef QT_NO_SYSTEMLOCALE
1468  if (d() == systemPrivate()) {
1471  time);
1472  if (!res.isNull())
1473  return res.toString();
1474  }
1475 #endif
1476 
1477  QString format_str = timeFormat(format);
1478  return toString(time, format_str);
1479 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
QString timeFormat(FormatType format=LongFormat) const
Returns the time format used for the current locale.
Definition: qlocale.cpp:1535
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566

◆ toString() [13/14]

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

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

Since
4.4

Definition at line 1436 of file qlocale.cpp.

1437 {
1438  if (!dateTime.isValid())
1439  return QString();
1440 
1441 #ifndef QT_NO_SYSTEMLOCALE
1442  if (d() == systemPrivate()) {
1446  dateTime);
1447  if (!res.isNull())
1448  return res.toString();
1449  }
1450 #endif
1451 
1452  const QString format_str = dateTimeFormat(format);
1453  return toString(dateTime, format_str);
1454 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
QString dateTimeFormat(FormatType format=LongFormat) const
Returns the date time format used for the current locale.
Definition: qlocale.cpp:1575
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
friend class QString
Definition: qlocale.h:138

◆ toString() [14/14]

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

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

Since
4.4

If format is an empty string, an empty string is returned.

Definition at line 1419 of file qlocale.cpp.

1420 {
1421  const QDate dt = dateTime.date();
1422  const QTime tm = dateTime.time();
1423  return d()->dateTimeToString(format, &dt, &tm, this);
1424 }
The QDate class provides date functions.
Definition: qdatetime.h:55
The QTime class provides clock time functions.
Definition: qdatetime.h:148
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time, const QLocale *q) const
Definition: qlocale.cpp:2389
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368

◆ toTime() [1/2]

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

Parses the time string given in string and returns the time.

Since
4.4

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.

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

Definition at line 1606 of file qlocale.cpp.

1607 {
1608  return toTime(string, timeFormat(format));
1609 }
QString timeFormat(FormatType format=LongFormat) const
Returns the time format used for the current locale.
Definition: qlocale.cpp:1535
QTime toTime(const QString &string, FormatType=LongFormat) const
Parses the time string given in string and returns the time.
Definition: qlocale.cpp:1606

◆ toTime() [2/2]

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

Parses the time string given in string and returns the time.

Since
4.4

See QTime::fromString() for information on what is a valid format string.

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

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

Definition at line 1670 of file qlocale.cpp.

1671 {
1672  QTime time;
1673 #ifndef QT_BOOTSTRAPPED
1675  dt.defaultLocale = *this;
1676  if (dt.parseFormat(format))
1677  dt.fromString(string, 0, &time);
1678 #else
1679  Q_UNUSED(string);
1680  Q_UNUSED(format);
1681 #endif
1682  return time;
1683 }
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ toUInt()

uint QLocale::toUInt ( const QString s,
bool *  ok = 0,
int  base = 0 
) const

Returns the unsigned int represented by the localized string s, using base base.

If base is 0 the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

If the conversion fails the function returns 0.

If ok is not 0, 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(), toString()

Definition at line 1161 of file qlocale.cpp.

Referenced by QDateTimeParser::parseSection().

1162 {
1163  qulonglong i = toULongLong(s, ok, base);
1164  if (i > UINT_MAX) {
1165  if (ok != 0)
1166  *ok = false;
1167  return 0;
1168  }
1169  return uint(i);
1170 }
static const uint base
Definition: qurl.cpp:268
qlonglong toULongLong(const QString &s, bool *ok=0, int base=0) const
Returns the unsigned long long int represented by the localized string s, using base base...
Definition: qlocale.cpp:1220
unsigned int uint
Definition: qglobal.h:996
quint64 qulonglong
Definition: qglobal.h:952

◆ toULongLong()

qlonglong QLocale::toULongLong ( const QString s,
bool *  ok = 0,
int  base = 0 
) const

Returns the unsigned long long int represented by the localized string s, using base base.

If base is 0 the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

If the conversion fails the function returns 0.

If ok is not 0, 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(), toString()

Definition at line 1220 of file qlocale.cpp.

Referenced by toUInt(), and toUShort().

1221 {
1226 
1227  return d()->stringToUnsLongLong(s, base, ok, mode);
1228 }
Data p
Definition: qlocale.h:803
static const uint base
Definition: qurl.cpp:268
quint64 stringToUnsLongLong(const QString &num, int base, bool *ok, GroupSeparatorMode group_sep_mode) const
Definition: qlocale.cpp:3119
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
quint16 numberOptions
Definition: qlocale.h:790

◆ toUpper()

QString QLocale::toUpper ( const QString str) const

Returns an uppercase copy of str.

Since
4.8

Definition at line 2307 of file qlocale.cpp.

2308 {
2309 #ifdef QT_USE_ICU
2310  {
2311  QString result;
2312  if (qt_u_strToUpper(str, &result, *this))
2313  return result;
2314  // else fall through and use Qt's toUpper
2315  }
2316 #endif
2317  return str.toUpper();
2318 }
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale)

◆ toUShort()

ushort QLocale::toUShort ( const QString s,
bool *  ok = 0,
int  base = 0 
) const

Returns the unsigned short int represented by the localized string s, using base base.

If base is 0 the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

If the conversion fails the function returns 0.

If ok is not 0, 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(), toString()

Definition at line 1105 of file qlocale.cpp.

1106 {
1107  qulonglong i = toULongLong(s, ok, base);
1108  if (i > USHRT_MAX) {
1109  if (ok != 0)
1110  *ok = false;
1111  return 0;
1112  }
1113  return ushort(i);
1114 }
static const uint base
Definition: qurl.cpp:268
qlonglong toULongLong(const QString &s, bool *ok=0, int base=0) const
Returns the unsigned long long int represented by the localized string s, using base base...
Definition: qlocale.cpp:1220
unsigned short ushort
Definition: qglobal.h:995
quint64 qulonglong
Definition: qglobal.h:952

◆ uiLanguages()

QStringList QLocale::uiLanguages ( ) const

Returns an ordered list of locale names for translation purposes in preference order.

Since
4.8

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.

See also
QTranslator, bcp47Name()

Definition at line 3410 of file qlocale.cpp.

Referenced by find_translation().

3411 {
3412 #ifndef QT_NO_SYSTEMLOCALE
3413  if (d() == systemPrivate()) {
3415  if (!res.isNull()) {
3416  QStringList result = res.toStringList();
3417  if (!result.isEmpty())
3418  return result;
3419  }
3420  }
3421 #endif
3422  return QStringList(bcp47Name());
3423 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
QString bcp47Name() const
Returns the dash-separated language, script and country (and possibly other BCP47 fields) of this loc...
Definition: qlocale.cpp:1012

◆ weekdays()

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

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

Since
4.8

Definition at line 2237 of file qlocale.cpp.

2238 {
2239 #ifndef QT_NO_SYSTEMLOCALE
2240  if (d() == systemPrivate()) {
2242  if (!res.isNull())
2243  return static_cast<QList<Qt::DayOfWeek> >(res.value<QList<Qt::DayOfWeek> >());
2244  }
2245 #endif
2247  quint16 weekendStart = d()->m_weekend_start;
2248  quint16 weekendEnd = d()->m_weekend_end;
2249  for (int day = Qt::Monday; day <= Qt::Sunday; day++) {
2250  if ((weekendEnd >= weekendStart && (day < weekendStart || day > weekendEnd)) ||
2251  (weekendEnd < weekendStart && (day > weekendEnd && day < weekendStart)))
2252  weekdays << static_cast<Qt::DayOfWeek>(day);
2253  }
2254  return weekdays;
2255 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static const QSystemLocale * systemLocale()
Definition: qlocale.cpp:471
QList< Qt::DayOfWeek > weekdays() const
Returns a list of days that are considered weekdays according to the current locale.
Definition: qlocale.cpp:2237
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
static const QLocalePrivate * systemPrivate()
Definition: qlocale.cpp:535
quint16 m_weekend_end
Definition: qlocale_p.h:220
unsigned short quint16
Definition: qglobal.h:936
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
virtual QVariant query(QueryType type, QVariant in) const
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
quint16 m_weekend_start
Definition: qlocale_p.h:219
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ zeroDigit()

QChar QLocale::zeroDigit ( ) const

Returns the zero digit character of this locale.

Since
4.1

Definition at line 1804 of file qlocale.cpp.

Referenced by QSystemLocale::query().

1805 {
1806  return d()->zero();
1807 }
QChar zero() const
Definition: qlocale_p.h:75
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

Friends and Related Functions

◆ QByteArray

friend class QByteArray
friend

Definition at line 139 of file qlocale.h.

◆ QDoubleValidatorPrivate

Definition at line 141 of file qlocale.h.

◆ QIntValidator

friend class QIntValidator
friend

Definition at line 140 of file qlocale.h.

◆ QLocalePrivate

friend struct QLocalePrivate
friend

Definition at line 798 of file qlocale.h.

◆ QString

friend class QString
friend

◆ QTextStream

friend class QTextStream
friend

Definition at line 142 of file qlocale.h.

◆ QTextStreamPrivate

friend class QTextStreamPrivate
friend

Definition at line 143 of file qlocale.h.

Properties

◆ @62

union { ... }

◆ p

Data QLocale::p

◆ v

void* QLocale::v

Definition at line 802 of file qlocale.h.

Referenced by operator=(), and QLocale().


The documentation for this class was generated from the following files: