#include <qlocale.h>
QLocale is initialized with a language/country pair in its constructor and offers number-to-string and string-to-number conversion functions similar to those in QString.
Example:
QLocale egyptian(QLocale::Arabic, QLocale::Egypt); QString s1 = egyptian.toString(1.571429E+07, 'e'); QString s2 = egyptian.toString(10); double d = egyptian.toDouble(s1); int i = egyptian.toInt(s2);
QLocale supports the concept of a default locale, which is determined from the system's locale settings at application startup. The default locale can be changed by calling the static member setDefault(). Setting the default locale has the following effects:
If a QLocale object is constructed with the default constructor, it will use the default locale's settings. QString::toInt(), QString::toDouble(), etc., interpret the string according to the default locale. If this fails, it falls back on the "C" locale. QString::arg() uses the default locale to format a number when its position specifier in the format string contains an 'L', e.g. "%L1".
The following example illustrates how to use QLocale directly:
QLocale::setDefault(QLocale(QLocale::Hebrew, QLocale::Israel)); QLocale hebrew; // Constructs a default QLocale QString s1 = hebrew.toString(15714.3, 'e'); bool ok; double d; QLocale::setDefault(QLocale::C); d = QString("1234,56").toDouble(&ok); // ok == false d = QString("1234.56").toDouble(&ok); // ok == true, d == 1234.56 QLocale::setDefault(QLocale::German); d = QString("1234,56").toDouble(&ok); // ok == true, d == 1234.56 d = QString("1234.56").toDouble(&ok); // ok == true, d == 1234.56 QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); str = QString("%1 %L2 %L3") .arg(12345).arg(12345).arg(12345, 0, 16); // str == "12345 12,345 3039"
When a language/country pair is specified in the constructor, one of three things can happen:
If the language/country pair is found in the database, it is used. If the language is found but the country is not, or if the country is AnyCountry, the language is used with the most appropriate available country (for example, Germany for German), If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).
The "C" locale is identical to {English}/{UnitedStates}.
Use language() and country() to determine the actual language and country values used.
An alternative method for constructing a QLocale object is by specifying the locale name.
This constructor converts the locale name to a language/country pair; it does not use the system locale database.
The double-to-string and string-to-double conversion functions are covered by the following licenses:
Copyright (c) 1991 by AT&T.
Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
This product includes software developed by the University of California, Berkeley and its contributors.
Definition at line 39 of file qlocale.h.
Public Types | |
| enum | Language |
| enum | Country |
| enum | FormatType |
| enum | NumberOption |
Public Member Functions | |
| QLocale () | |
| QLocale (const QString &name) | |
| QLocale (Language language, Country country=AnyCountry) | |
| QLocale (const QLocale &other) | |
| QLocale & | operator= (const QLocale &other) |
| Language | language () const |
| Country | country () const |
| QString | name () const |
| short | toShort (const QString &s, bool *ok=0, int base=0) const |
| ushort | toUShort (const QString &s, bool *ok=0, int base=0) const |
| int | toInt (const QString &s, bool *ok=0, int base=0) const |
| uint | toUInt (const QString &s, bool *ok=0, int base=0) const |
| qlonglong | toLongLong (const QString &s, bool *ok=0, int base=0) const |
| qlonglong | toULongLong (const QString &s, bool *ok=0, int base=0) const |
| float | toFloat (const QString &s, bool *ok=0) const |
| double | toDouble (const QString &s, bool *ok=0) const |
| QString | toString (qlonglong i) const |
| QString | toString (qulonglong i) const |
| QString | toString (short i) const |
| QString | toString (ushort i) const |
| QString | toString (int i) const |
| QString | toString (uint i) const |
| QString | toString (double i, char f= 'g', int prec=6) const |
| QString | toString (float i, char f= 'g', int prec=6) const |
| QString | toString (const QDate &date, const QString &formatStr) const |
| QString | toString (const QDate &date, FormatType format=LongFormat) const |
| QString | toString (const QTime &time, const QString &formatStr) const |
| QString | toString (const QTime &time, FormatType format=LongFormat) const |
| QString | dateFormat (FormatType format=LongFormat) const |
| QString | timeFormat (FormatType format=LongFormat) const |
| QChar | decimalPoint () const |
| QChar | groupSeparator () const |
| QChar | percent () const |
| QChar | zeroDigit () const |
| QChar | negativeSign () const |
| QChar | exponential () const |
| QString | monthName (int, FormatType format=LongFormat) const |
| QString | dayName (int, FormatType format=LongFormat) const |
| bool | operator== (const QLocale &other) const |
| bool | operator!= (const QLocale &other) const |
| void | setNumberOptions (NumberOptions options) |
| NumberOptions | numberOptions () const |
Static Public Member Functions | |
| static QString | languageToString (Language language) |
| static QString | countryToString (Country country) |
| static void | setDefault (const QLocale &locale) |
| static QLocale | c () |
| static QLocale | system () |
Private Member Functions | |
| const QLocalePrivate * | d () const |
Private Attributes | |
| void * | v |
Friends | |
| class | QString |
| class | QByteArray |
| struct | QLocalePrivate |
| enum QLocale::Language |
This enumerated type is used to specify a language.
C Abkhazian Afan Afar Afrikaans Albanian Amharic Arabic Armenian Assamese Aymara Azerbaijani Bashkir Basque Bengali Bhutani Bihari Bislama Bosnian Breton Bulgarian Burmese Byelorussian Cambodian Catalan Chinese Cornish Corsican Croatian Czech Danish Divehi 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 Kurundi Laothian Latin Latvian Lingala Lithuanian Macedonian Malagasy Malay Malayalam Maltese Manx Maori Marathi Moldavian Mongolian NauruLanguage Nepali Norwegian Nynorsk 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 LastLanguage
Definition at line 45 of file qlocale.h.
00045 { 00046 C = 1, 00047 Abkhazian = 2, 00048 Afan = 3, 00049 Afar = 4, 00050 Afrikaans = 5, 00051 Albanian = 6, 00052 Amharic = 7, 00053 Arabic = 8, 00054 Armenian = 9, 00055 Assamese = 10, 00056 Aymara = 11, 00057 Azerbaijani = 12, 00058 Bashkir = 13, 00059 Basque = 14, 00060 Bengali = 15, 00061 Bhutani = 16, 00062 Bihari = 17, 00063 Bislama = 18, 00064 Breton = 19, 00065 Bulgarian = 20, 00066 Burmese = 21, 00067 Byelorussian = 22, 00068 Cambodian = 23, 00069 Catalan = 24, 00070 Chinese = 25, 00071 Corsican = 26, 00072 Croatian = 27, 00073 Czech = 28, 00074 Danish = 29, 00075 Dutch = 30, 00076 English = 31, 00077 Esperanto = 32, 00078 Estonian = 33, 00079 Faroese = 34, 00080 FijiLanguage = 35, 00081 Finnish = 36, 00082 French = 37, 00083 Frisian = 38, 00084 Gaelic = 39, 00085 Galician = 40, 00086 Georgian = 41, 00087 German = 42, 00088 Greek = 43, 00089 Greenlandic = 44, 00090 Guarani = 45, 00091 Gujarati = 46, 00092 Hausa = 47, 00093 Hebrew = 48, 00094 Hindi = 49, 00095 Hungarian = 50, 00096 Icelandic = 51, 00097 Indonesian = 52, 00098 Interlingua = 53, 00099 Interlingue = 54, 00100 Inuktitut = 55, 00101 Inupiak = 56, 00102 Irish = 57, 00103 Italian = 58, 00104 Japanese = 59, 00105 Javanese = 60, 00106 Kannada = 61, 00107 Kashmiri = 62, 00108 Kazakh = 63, 00109 Kinyarwanda = 64, 00110 Kirghiz = 65, 00111 Korean = 66, 00112 Kurdish = 67, 00113 Kurundi = 68, 00114 Laothian = 69, 00115 Latin = 70, 00116 Latvian = 71, 00117 Lingala = 72, 00118 Lithuanian = 73, 00119 Macedonian = 74, 00120 Malagasy = 75, 00121 Malay = 76, 00122 Malayalam = 77, 00123 Maltese = 78, 00124 Maori = 79, 00125 Marathi = 80, 00126 Moldavian = 81, 00127 Mongolian = 82, 00128 NauruLanguage = 83, 00129 Nepali = 84, 00130 Norwegian = 85, 00131 Occitan = 86, 00132 Oriya = 87, 00133 Pashto = 88, 00134 Persian = 89, 00135 Polish = 90, 00136 Portuguese = 91, 00137 Punjabi = 92, 00138 Quechua = 93, 00139 RhaetoRomance = 94, 00140 Romanian = 95, 00141 Russian = 96, 00142 Samoan = 97, 00143 Sangho = 98, 00144 Sanskrit = 99, 00145 Serbian = 100, 00146 SerboCroatian = 101, 00147 Sesotho = 102, 00148 Setswana = 103, 00149 Shona = 104, 00150 Sindhi = 105, 00151 Singhalese = 106, 00152 Siswati = 107, 00153 Slovak = 108, 00154 Slovenian = 109, 00155 Somali = 110, 00156 Spanish = 111, 00157 Sundanese = 112, 00158 Swahili = 113, 00159 Swedish = 114, 00160 Tagalog = 115, 00161 Tajik = 116, 00162 Tamil = 117, 00163 Tatar = 118, 00164 Telugu = 119, 00165 Thai = 120, 00166 Tibetan = 121, 00167 Tigrinya = 122, 00168 TongaLanguage = 123, 00169 Tsonga = 124, 00170 Turkish = 125, 00171 Turkmen = 126, 00172 Twi = 127, 00173 Uigur = 128, 00174 Ukrainian = 129, 00175 Urdu = 130, 00176 Uzbek = 131, 00177 Vietnamese = 132, 00178 Volapuk = 133, 00179 Welsh = 134, 00180 Wolof = 135, 00181 Xhosa = 136, 00182 Yiddish = 137, 00183 Yoruba = 138, 00184 Zhuang = 139, 00185 Zulu = 140, 00186 Nynorsk = 141, 00187 Bosnian = 142, 00188 Divehi = 143, 00189 Manx = 144, 00190 Cornish = 145, 00191 LastLanguage = Cornish 00192 };
| enum QLocale::Country |
This enumerated type is used to specify a country.
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 SerbiaAndMontenegro 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 LastCountry
Definition at line 194 of file qlocale.h.
00194 { 00195 AnyCountry = 0, 00196 Afghanistan = 1, 00197 Albania = 2, 00198 Algeria = 3, 00199 AmericanSamoa = 4, 00200 Andorra = 5, 00201 Angola = 6, 00202 Anguilla = 7, 00203 Antarctica = 8, 00204 AntiguaAndBarbuda = 9, 00205 Argentina = 10, 00206 Armenia = 11, 00207 Aruba = 12, 00208 Australia = 13, 00209 Austria = 14, 00210 Azerbaijan = 15, 00211 Bahamas = 16, 00212 Bahrain = 17, 00213 Bangladesh = 18, 00214 Barbados = 19, 00215 Belarus = 20, 00216 Belgium = 21, 00217 Belize = 22, 00218 Benin = 23, 00219 Bermuda = 24, 00220 Bhutan = 25, 00221 Bolivia = 26, 00222 BosniaAndHerzegowina = 27, 00223 Botswana = 28, 00224 BouvetIsland = 29, 00225 Brazil = 30, 00226 BritishIndianOceanTerritory = 31, 00227 BruneiDarussalam = 32, 00228 Bulgaria = 33, 00229 BurkinaFaso = 34, 00230 Burundi = 35, 00231 Cambodia = 36, 00232 Cameroon = 37, 00233 Canada = 38, 00234 CapeVerde = 39, 00235 CaymanIslands = 40, 00236 CentralAfricanRepublic = 41, 00237 Chad = 42, 00238 Chile = 43, 00239 China = 44, 00240 ChristmasIsland = 45, 00241 CocosIslands = 46, 00242 Colombia = 47, 00243 Comoros = 48, 00244 DemocraticRepublicOfCongo = 49, 00245 PeoplesRepublicOfCongo = 50, 00246 CookIslands = 51, 00247 CostaRica = 52, 00248 IvoryCoast = 53, 00249 Croatia = 54, 00250 Cuba = 55, 00251 Cyprus = 56, 00252 CzechRepublic = 57, 00253 Denmark = 58, 00254 Djibouti = 59, 00255 Dominica = 60, 00256 DominicanRepublic = 61, 00257 EastTimor = 62, 00258 Ecuador = 63, 00259 Egypt = 64, 00260 ElSalvador = 65, 00261 EquatorialGuinea = 66, 00262 Eritrea = 67, 00263 Estonia = 68, 00264 Ethiopia = 69, 00265 FalklandIslands = 70, 00266 FaroeIslands = 71, 00267 FijiCountry = 72, 00268 Finland = 73, 00269 France = 74, 00270 MetropolitanFrance = 75, 00271 FrenchGuiana = 76, 00272 FrenchPolynesia = 77, 00273 FrenchSouthernTerritories = 78, 00274 Gabon = 79, 00275 Gambia = 80, 00276 Georgia = 81, 00277 Germany = 82, 00278 Ghana = 83, 00279 Gibraltar = 84, 00280 Greece = 85, 00281 Greenland = 86, 00282 Grenada = 87, 00283 Guadeloupe = 88, 00284 Guam = 89, 00285 Guatemala = 90, 00286 Guinea = 91, 00287 GuineaBissau = 92, 00288 Guyana = 93, 00289 Haiti = 94, 00290 HeardAndMcDonaldIslands = 95, 00291 Honduras = 96, 00292 HongKong = 97, 00293 Hungary = 98, 00294 Iceland = 99, 00295 India = 100, 00296 Indonesia = 101, 00297 Iran = 102, 00298 Iraq = 103, 00299 Ireland = 104, 00300 Israel = 105, 00301 Italy = 106, 00302 Jamaica = 107, 00303 Japan = 108, 00304 Jordan = 109, 00305 Kazakhstan = 110, 00306 Kenya = 111, 00307 Kiribati = 112, 00308 DemocraticRepublicOfKorea = 113, 00309 RepublicOfKorea = 114, 00310 Kuwait = 115, 00311 Kyrgyzstan = 116, 00312 Lao = 117, 00313 Latvia = 118, 00314 Lebanon = 119, 00315 Lesotho = 120, 00316 Liberia = 121, 00317 LibyanArabJamahiriya = 122, 00318 Liechtenstein = 123, 00319 Lithuania = 124, 00320 Luxembourg = 125, 00321 Macau = 126, 00322 Macedonia = 127, 00323 Madagascar = 128, 00324 Malawi = 129, 00325 Malaysia = 130, 00326 Maldives = 131, 00327 Mali = 132, 00328 Malta = 133, 00329 MarshallIslands = 134, 00330 Martinique = 135, 00331 Mauritania = 136, 00332 Mauritius = 137, 00333 Mayotte = 138, 00334 Mexico = 139, 00335 Micronesia = 140, 00336 Moldova = 141, 00337 Monaco = 142, 00338 Mongolia = 143, 00339 Montserrat = 144, 00340 Morocco = 145, 00341 Mozambique = 146, 00342 Myanmar = 147, 00343 Namibia = 148, 00344 NauruCountry = 149, 00345 Nepal = 150, 00346 Netherlands = 151, 00347 NetherlandsAntilles = 152, 00348 NewCaledonia = 153, 00349 NewZealand = 154, 00350 Nicaragua = 155, 00351 Niger = 156, 00352 Nigeria = 157, 00353 Niue = 158, 00354 NorfolkIsland = 159, 00355 NorthernMarianaIslands = 160, 00356 Norway = 161, 00357 Oman = 162, 00358 Pakistan = 163, 00359 Palau = 164, 00360 PalestinianTerritory = 165, 00361 Panama = 166, 00362 PapuaNewGuinea = 167, 00363 Paraguay = 168, 00364 Peru = 169, 00365 Philippines = 170, 00366 Pitcairn = 171, 00367 Poland = 172, 00368 Portugal = 173, 00369 PuertoRico = 174, 00370 Qatar = 175, 00371 Reunion = 176, 00372 Romania = 177, 00373 RussianFederation = 178, 00374 Rwanda = 179, 00375 SaintKittsAndNevis = 180, 00376 StLucia = 181, 00377 StVincentAndTheGrenadines = 182, 00378 Samoa = 183, 00379 SanMarino = 184, 00380 SaoTomeAndPrincipe = 185, 00381 SaudiArabia = 186, 00382 Senegal = 187, 00383 Seychelles = 188, 00384 SierraLeone = 189, 00385 Singapore = 190, 00386 Slovakia = 191, 00387 Slovenia = 192, 00388 SolomonIslands = 193, 00389 Somalia = 194, 00390 SouthAfrica = 195, 00391 SouthGeorgiaAndTheSouthSandwichIslands = 196, 00392 Spain = 197, 00393 SriLanka = 198, 00394 StHelena = 199, 00395 StPierreAndMiquelon = 200, 00396 Sudan = 201, 00397 Suriname = 202, 00398 SvalbardAndJanMayenIslands = 203, 00399 Swaziland = 204, 00400 Sweden = 205, 00401 Switzerland = 206, 00402 SyrianArabRepublic = 207, 00403 Taiwan = 208, 00404 Tajikistan = 209, 00405 Tanzania = 210, 00406 Thailand = 211, 00407 Togo = 212, 00408 Tokelau = 213, 00409 TongaCountry = 214, 00410 TrinidadAndTobago = 215, 00411 Tunisia = 216, 00412 Turkey = 217, 00413 Turkmenistan = 218, 00414 TurksAndCaicosIslands = 219, 00415 Tuvalu = 220, 00416 Uganda = 221, 00417 Ukraine = 222, 00418 UnitedArabEmirates = 223, 00419 UnitedKingdom = 224, 00420 UnitedStates = 225, 00421 UnitedStatesMinorOutlyingIslands = 226, 00422 Uruguay = 227, 00423 Uzbekistan = 228, 00424 Vanuatu = 229, 00425 VaticanCityState = 230, 00426 Venezuela = 231, 00427 VietNam = 232, 00428 BritishVirginIslands = 233, 00429 USVirginIslands = 234, 00430 WallisAndFutunaIslands = 235, 00431 WesternSahara = 236, 00432 Yemen = 237, 00433 Yugoslavia = 238, 00434 Zambia = 239, 00435 Zimbabwe = 240, 00436 SerbiaAndMontenegro = 241, 00437 LastCountry = SerbiaAndMontenegro 00438 };
| enum QLocale::FormatType |
This enum describes the types of format that can be used when converting QDate and QTime objects to strings.
LongFormat ShortFormat
Definition at line 440 of file qlocale.h.
00440 { LongFormat, ShortFormat };
This enum defines a set of options for number-to-string and string-to-number conversions. They can be retrieved with numberOptions() and set with setNumberOptions().
OmitGroupSeparator If this option is set, the number-to-string functions will not insert group separators in their return values. The default is to insert group seperators. RejectGroupSeparator If this option is set, the string-to-number functions will fail if they encounter group separators in their input. The default is to accept numbers containing correctly placed group separators.
Definition at line 441 of file qlocale.h.
00441 { OmitGroupSeparator = 0x01, RejectGroupSeparator = 0x02 };
| 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().
Definition at line 1947 of file qlocale.cpp.
References defaultPrivate(), setDataPointer(), setNumberOptions(), and v.
01948 { 01949 ::setDataPointer(&v, defaultPrivate()); 01950 ::setNumberOptions(&v, 0); 01951 }
Here is the call graph for this function:

| QLocale::QLocale | ( | const QString & | name | ) |
Constructs a QLocale object with the specified name, which has the format "language[_country][.codeset][@modifier]" or "C", where:
language is a lowercase, two-letter, ISO 639 language code, territory is an uppercase, two-letter, ISO 3166 country code, and codeset and modifier are ignored.
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 and country codes are converted to their respective Language and Country enums. After this conversion is performed the constructor behaves exactly like QLocale(Country, Language).
This constructor is much slower than QLocale(Country, Language).
Definition at line 1933 of file qlocale.cpp.
References findLocale(), name(), setDataPointer(), setNumberOptions(), and v.
01934 { 01935 ::setDataPointer(&v, findLocale(name)); 01936 ::setNumberOptions(&v, 0); 01937 }
Here is the call graph for this function:

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().
Definition at line 1972 of file qlocale.cpp.
References C, d(), defaultPrivate(), findLocale(), QLocalePrivate::languageId(), setDataPointer(), setNumberOptions(), and v.
01973 { 01974 const QLocalePrivate *d = findLocale(language, country); 01975 01976 // If not found, should default to system 01977 if (d->languageId() == QLocale::C && language != QLocale::C) 01978 d = defaultPrivate(); 01979 01980 ::setDataPointer(&v, d); 01981 ::setNumberOptions(&v, 0); 01982 }
Here is the call graph for this function:

| QLocale::QLocale | ( | const QLocale & | other | ) |
| QLocale::Language QLocale::language | ( | ) | const |
Returns the language of this locale.
Definition at line 2058 of file qlocale.cpp.
References d().
Referenced by QResourceRoot::findNode(), RCCResourceLibrary::interpretResourceFile(), MetaTranslator::languageAndCountry(), MessageModel::load(), and name().
Here is the call graph for this function:

| QLocale::Country QLocale::country | ( | ) | const |
Returns the country of this locale.
Definition at line 2068 of file qlocale.cpp.
References d().
Referenced by QResourceRoot::findNode(), RCCResourceLibrary::interpretResourceFile(), MetaTranslator::languageAndCountry(), MessageModel::load(), and name().
Here is the call graph for this function:

| 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-letter ISO 3166 country code.
Definition at line 2082 of file qlocale.cpp.
References AnyCountry, QString::append(), c(), C, country(), countryToCode(), language(), and languageToCode().
Referenced by QKeyMapperPrivate::clearMappings(), QSvgSwitch::init(), main(), QLocale(), MessageModel::release(), and MessageModel::save().
02083 { 02084 Language l = language(); 02085 02086 QString result = languageToCode(l); 02087 02088 if (l == C) 02089 return result; 02090 02091 Country c = country(); 02092 if (c == AnyCountry) 02093 return result; 02094 02095 result.append(QLatin1Char('_')); 02096 result.append(countryToCode(c)); 02097 02098 return result; 02099 }
Here is the call graph for this function:

| 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.
Definition at line 2144 of file qlocale.cpp.
References s, and toLongLong().
02145 { 02146 qlonglong i = toLongLong(s, ok, base); 02147 if (i < SHRT_MIN || i > SHRT_MAX) { 02148 if (ok != 0) 02149 *ok = false; 02150 return 0; 02151 } 02152 return short(i); 02153 }
Here is the call graph for this function:

| 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.
Definition at line 2172 of file qlocale.cpp.
References s, and toULongLong().
02173 { 02174 qulonglong i = toULongLong(s, ok, base); 02175 if (i > USHRT_MAX) { 02176 if (ok != 0) 02177 *ok = false; 02178 return 0; 02179 } 02180 return ushort(i); 02181 }
Here is the call graph for this function:

| 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.
Definition at line 2200 of file qlocale.cpp.
References int, s, and toLongLong().
02201 { 02202 qlonglong i = toLongLong(s, ok, base); 02203 if (i < INT_MIN || i > INT_MAX) { 02204 if (ok != 0) 02205 *ok = false; 02206 return 0; 02207 } 02208 return int(i); 02209 }
Here is the call graph for this function:

| 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.
Definition at line 2228 of file qlocale.cpp.
References s, and toULongLong().
Referenced by QDateTimeParser::parseSection().
02229 { 02230 qulonglong i = toULongLong(s, ok, base); 02231 if (i > UINT_MAX) { 02232 if (ok != 0) 02233 *ok = false; 02234 return 0; 02235 } 02236 return uint(i); 02237 }
Here is the call graph for this function:

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.
Definition at line 2257 of file qlocale.cpp.
References d(), QLocalePrivate::FailOnGroupSeparators, numberOptions(), QLocalePrivate::ParseGroupSeparators, RejectGroupSeparator, s, QLocalePrivate::stringToLongLong(), and v.
Referenced by toInt(), and toShort().
02258 { 02259 QLocalePrivate::GroupSeparatorMode mode 02260 = ::numberOptions(v) & RejectGroupSeparator 02261 ? QLocalePrivate::FailOnGroupSeparators 02262 : QLocalePrivate::ParseGroupSeparators; 02263 02264 return d()->stringToLongLong(s, base, ok, mode); 02265 }
Here is the call graph for this function:

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.
Definition at line 2285 of file qlocale.cpp.
References d(), QLocalePrivate::FailOnGroupSeparators, numberOptions(), QLocalePrivate::ParseGroupSeparators, RejectGroupSeparator, s, QLocalePrivate::stringToUnsLongLong(), and v.
Referenced by toUInt(), and toUShort().
02286 { 02287 QLocalePrivate::GroupSeparatorMode mode 02288 = ::numberOptions(v) & RejectGroupSeparator 02289 ? QLocalePrivate::FailOnGroupSeparators 02290 : QLocalePrivate::ParseGroupSeparators; 02291 02292 return d()->stringToUnsLongLong(s, base, ok, mode); 02293 }
Here is the call graph for this function:

| float QLocale::toFloat | ( | const QString & | s, | |
| bool * | ok = 0 | |||
| ) | const |
Definition at line 2309 of file qlocale.cpp.
References d(), QT_MAX_FLOAT, s, and toDouble().
02310 { 02311 bool myOk; 02312 double d = toDouble(s, &myOk); 02313 if (!myOk || d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) { 02314 if (ok != 0) 02315 *ok = false; 02316 return 0.0; 02317 } 02318 if (ok != 0) 02319 *ok = true; 02320 return float(d); 02321 }
Here is the call graph for this function:

| 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; QLocale c(QLocale::C); d = c.toDouble( "1234.56", &ok ); // ok == true, d == 1234.56 d = c.toDouble( "1,234.56", &ok ); // ok == true, d == 1234.56 d = c.toDouble( "1234,56", &ok ); // ok == false QLocale german(QLocale::German); d = german.toDouble( "1234,56", &ok ); // ok == true, d == 1234.56 d = german.toDouble( "1.234,56", &ok ); // ok == true, d == 1234.56 d = german.toDouble( "1234.56", &ok ); // ok == false d = german.toDouble( "1.234", &ok ); // ok == true, d == 1234.0
Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.
This function ignores leading and trailing whitespace.
Definition at line 2359 of file qlocale.cpp.
References d(), QLocalePrivate::FailOnGroupSeparators, numberOptions(), QLocalePrivate::ParseGroupSeparators, RejectGroupSeparator, s, QLocalePrivate::stringToDouble(), and v.
Referenced by toFloat(), and QDoubleSpinBoxPrivate::validateAndInterpret().
02360 { 02361 QLocalePrivate::GroupSeparatorMode mode 02362 = ::numberOptions(v) & RejectGroupSeparator 02363 ? QLocalePrivate::FailOnGroupSeparators 02364 : QLocalePrivate::ParseGroupSeparators; 02365 02366 return d()->stringToDouble(s, ok, mode); 02367 }
Here is the call graph for this function:

Returns a localized string representation of i.
Definition at line 2375 of file qlocale.cpp.
References d(), QLocalePrivate::longLongToString(), numberOptions(), OmitGroupSeparator, QLocalePrivate::ThousandsGroup, and v.
Referenced by toString(), QDate::toString(), and QTime::toString().
02376 { 02377 int flags = ::numberOptions(v) & OmitGroupSeparator 02378 ? 0 02379 : QLocalePrivate::ThousandsGroup; 02380 02381 return d()->longLongToString(i, -1, 10, -1, flags); 02382 }
Here is the call graph for this function:

| 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.
Definition at line 2390 of file qlocale.cpp.
References d(), numberOptions(), OmitGroupSeparator, QLocalePrivate::ThousandsGroup, QLocalePrivate::unsLongLongToString(), and v.
02391 { 02392 int flags = ::numberOptions(v) & OmitGroupSeparator 02393 ? 0 02394 : QLocalePrivate::ThousandsGroup; 02395 02396 return d()->unsLongLongToString(i, -1, 10, -1, flags); 02397 }
Here is the call graph for this function:

| QString QLocale::toString | ( | short | i | ) | const [inline] |
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 513 of file qlocale.h.
References toString().
Here is the call graph for this function:

| QString QLocale::toString | ( | ushort | i | ) | const [inline] |
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 515 of file qlocale.h.
References toString().
00516 { return toString(qulonglong(i)); }
Here is the call graph for this function:

| QString QLocale::toString | ( | int | i | ) | const [inline] |
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 517 of file qlocale.h.
References toString().
Here is the call graph for this function:

| QString QLocale::toString | ( | uint | i | ) | const [inline] |
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 519 of file qlocale.h.
References toString().
00520 { return toString(qulonglong(i)); }
Here is the call graph for this function:

| 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).
Definition at line 2854 of file qlocale.cpp.
References QLocalePrivate::CapitalEorX, d(), QLocalePrivate::DFDecimal, QLocalePrivate::DFExponent, QLocalePrivate::DFSignificantDigits, QLocalePrivate::doubleToString(), form(), numberOptions(), OmitGroupSeparator, qIsUpper(), qToLower, QLocalePrivate::ThousandsGroup, and v.
02855 { 02856 QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; 02857 uint flags = 0; 02858 02859 if (qIsUpper(f)) 02860 flags = QLocalePrivate::CapitalEorX; 02861 f = qToLower(f); 02862 02863 switch (f) { 02864 case 'f': 02865 form = QLocalePrivate::DFDecimal; 02866 break; 02867 case 'e': 02868 form = QLocalePrivate::DFExponent; 02869 break; 02870 case 'g': 02871 form = QLocalePrivate::DFSignificantDigits; 02872 break; 02873 default: 02874 break; 02875 } 02876 02877 if (!(::numberOptions(v) & OmitGroupSeparator)) 02878 flags |= QLocalePrivate::ThousandsGroup; 02879 return d()->doubleToString(i, prec, form, -1, flags); 02880 }
Here is the call graph for this function:

| QString QLocale::toString | ( | float | i, | |
| char | f = 'g', |
|||
| int | prec = 6 | |||
| ) | const [inline] |
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).
Definition at line 521 of file qlocale.h.
References toString().
Here is the call graph for this function:

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 2405 of file qlocale.cpp.
References QString::append(), c(), d(), QDate::day(), dayName(), QDate::dayOfWeek(), LongFormat, QDate::month(), monthName(), QString, readEscapedFormatString(), repeatCount(), ShortFormat, QDate::year(), and QLocalePrivate::ZeroPadded.
02406 { 02407 QString result; 02408 02409 int i = 0; 02410 while (i < format.size()) { 02411 if (format.at(i).unicode() == '\'') { 02412 result.append(readEscapedFormatString(format, &i)); 02413 continue; 02414 } 02415 02416 QChar c = format.at(i); 02417 int repeat = repeatCount(format, i); 02418 02419 switch (c.unicode()) { 02420 case 'y': 02421 if (repeat >= 4) 02422 repeat = 4; 02423 else if (repeat >= 2) 02424 repeat = 2; 02425 02426 switch (repeat) { 02427 case 4: 02428 result.append(d()->longLongToString(date.year())); 02429 break; 02430 case 2: 02431 result.append(d()->longLongToString(date.year()%100, -1, 10, 2, QLocalePrivate::ZeroPadded)); 02432 break; 02433 default: 02434 repeat = 1; 02435 result.append(c); 02436 break; 02437 } 02438 break; 02439 02440 case 'M': 02441 if (repeat > 4) 02442 repeat = 4; 02443 switch (repeat) { 02444 case 1: 02445 result.append(d()->longLongToString(date.month())); 02446 break; 02447 case 2: 02448 result.append(d()->longLongToString(date.month(), -1, 10, 2, QLocalePrivate::ZeroPadded)); 02449 break; 02450 case 3: 02451 result.append(monthName(date.month(), QLocale::ShortFormat)); 02452 break; 02453 case 4: 02454 result.append(monthName(date.month(), QLocale::LongFormat)); 02455 break; 02456 } 02457 break; 02458 02459 case 'd': 02460 if (repeat > 4) 02461 repeat = 4; 02462 switch (repeat) { 02463 case 1: 02464 result.append(d()->longLongToString(date.day())); 02465 break; 02466 case 2: 02467 result.append(d()->longLongToString(date.day(), -1, 10, 2, QLocalePrivate::ZeroPadded)); 02468 break; 02469 case 3: 02470 result.append(dayName(date.dayOfWeek(), QLocale::ShortFormat)); 02471 break; 02472 case 4: 02473 result.append(dayName(date.dayOfWeek(), QLocale::LongFormat)); 02474 break; 02475 } 02476 break; 02477 02478 default: 02479 result.append(QString(repeat, c)); 02480 break; 02481 } 02482 02483 i += repeat; 02484 } 02485 02486 return result; 02487 }
Here is the call graph for this function:

| 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 2493 of file qlocale.cpp.
References d(), dateFormat(), QSystemLocale::DateToStringLong, QSystemLocale::DateToStringShort, QVariant::isNull(), QSystemLocale::query(), ShortFormat, systemLocale(), systemPrivate(), toString(), and QVariant::toString().
02494 { 02495 #ifndef QT_NO_SYSTEMLOCALE 02496 if (d() == systemPrivate()) { 02497 QVariant res = systemLocale()->query(format == ShortFormat 02498 ? QSystemLocale::DateToStringShort : QSystemLocale::DateToStringLong, 02499 date); 02500 if (!res.isNull()) 02501 return res.toString(); 02502 } 02503 #endif 02504 02505 QString format_str = dateFormat(format); 02506 return toString(date, format_str); 02507 }
Here is the call graph for this function:

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 2553 of file qlocale.cpp.
References QString::append(), c(), d(), QTime::hour(), QTime::minute(), QTime::msec(), QString, readEscapedFormatString(), repeatCount(), QTime::second(), timeFormatContainsAP(), timeZone(), and QLocalePrivate::ZeroPadded.
02554 { 02555 QString result; 02556 02557 int hour12 = time.hour(); 02558 enum { AM, PM } am_pm = AM; 02559 if (hour12 == 0) { 02560 am_pm = AM; 02561 hour12 = 12; 02562 } else if (hour12 < 12) { 02563 am_pm = AM; 02564 } else if (hour12 == 12) { 02565 am_pm = PM; 02566 } else { 02567 am_pm = PM; 02568 hour12 -= 12; 02569 } 02570 02571 bool format_am_pm = timeFormatContainsAP(format); 02572 02573 int i = 0; 02574 02575 while (i < format.size()) { 02576 if (format.at(i).unicode() == '\'') { 02577 result.append(readEscapedFormatString(format, &i)); 02578 continue; 02579 } 02580 02581 QChar c = format.at(i); 02582 int repeat = repeatCount(format, i); 02583 02584 switch (c.unicode()) { 02585 case 'h': { 02586 if (repeat > 2) 02587 repeat = 2; 02588 02589 int hour = format_am_pm ? hour12 : time.hour(); 02590 02591 switch (repeat) { 02592 case 1: 02593 result.append(d()->longLongToString(hour)); 02594 break; 02595 case 2: 02596 result.append(d()->longLongToString(hour, -1, 10, 2, QLocalePrivate::ZeroPadded)); 02597 break; 02598 } 02599 break; 02600 } 02601 case 'H': 02602 if (repeat > 2) 02603 repeat = 2; 02604 02605 switch (repeat) { 02606 case 1: 02607 result.append(d()->longLongToString(time.hour())); 02608 break; 02609 case 2: 02610 result.append(d()->longLongToString(time.hour(), -1, 10, 2, QLocalePrivate::ZeroPadded)); 02611 break; 02612 } 02613 break; 02614 02615 case 'm': 02616 if (repeat > 2) 02617 repeat = 2; 02618 switch (repeat) { 02619 case 1: 02620 result.append(d()->longLongToString(time.minute())); 02621 break; 02622 case 2: 02623 result.append(d()->longLongToString(time.minute(), -1, 10, 2, QLocalePrivate::ZeroPadded)); 02624 break; 02625 } 02626 break; 02627 02628 case 's': 02629 if (repeat > 2) 02630 repeat = 2; 02631 switch (repeat) { 02632 case 1: 02633 result.append(d()->longLongToString(time.second())); 02634 break; 02635 case 2: 02636 result.append(d()->longLongToString(time.second(), -1, 10, 2, QLocalePrivate::ZeroPadded)); 02637 break; 02638 } 02639 break; 02640 02641 case 'a': 02642 if (i + 1 < format.length() && format.at(i + 1).unicode() == 'p') { 02643 repeat = 2; 02644 result.append(am_pm == AM ? QLatin1String("am") : QLatin1String("pm")); 02645 } else { 02646 repeat = 1; 02647 result.append(c); 02648 } 02649 break; 02650 02651 case 'A': 02652 if (i + 1 < format.length() && format.at(i + 1).unicode() == 'P') { 02653 repeat = 2; 02654 result.append(am_pm == AM ? QLatin1String("AM") : QLatin1String("PM")); 02655 } else { 02656 repeat = 1; 02657 result.append(c); 02658 } 02659 break; 02660 02661 case 'z': 02662 if (repeat >= 3) 02663 repeat = 3; 02664 else if (repeat >= 1) 02665 repeat = 1; 02666 02667 switch (repeat) { 02668 case 1: 02669 result.append(d()->longLongToString(time.msec())); 02670 break; 02671 case 3: 02672 result.append(d()->longLongToString(time.msec(), -1, 10, 3, QLocalePrivate::ZeroPadded)); 02673 break; 02674 } 02675 break; 02676 02677 case 't': 02678 repeat = 1; 02679 result.append(timeZone()); 02680 break; 02681 02682 default: 02683 result.append(QString(repeat, c)); 02684 break; 02685 } 02686 02687 i += repeat; 02688 } 02689 02690 return result; 02691 }
Here is the call graph for this function:

| 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 2697 of file qlocale.cpp.
References d(), QVariant::isNull(), QSystemLocale::query(), ShortFormat, systemLocale(), systemPrivate(), timeFormat(), QSystemLocale::TimeToStringLong, QSystemLocale::TimeToStringShort, toString(), and QVariant::toString().
02698 { 02699 #ifndef QT_NO_SYSTEMLOCALE 02700 if (d() == systemPrivate()) { 02701 QVariant res = systemLocale()->query(format == ShortFormat 02702 ? QSystemLocale::TimeToStringShort : QSystemLocale::TimeToStringLong, 02703 time); 02704 if (!res.isNull()) 02705 return res.toString(); 02706 } 02707 #endif 02708 02709 QString format_str = timeFormat(format); 02710 return toString(time, format_str); 02711 }
Here is the call graph for this function:

| QString QLocale::dateFormat | ( | FormatType | format = LongFormat |
) | const |
If format is ShortFormat the format will be a short version. Otherwise it uses a longer version.
Definition at line 2724 of file qlocale.cpp.
References d(), date_format_data, QSystemLocale::DateFormatLong, QSystemLocale::DateFormatShort, QString::fromUtf8(), QVariant::isNull(), QLocalePrivate::m_long_date_format_idx, QLocalePrivate::m_short_date_format_idx, QSystemLocale::query(), ShortFormat, systemLocale(), systemPrivate(), and QVariant::toString().
Referenced by QDateTimeEditPrivate::readLocaleSettings(), and toString().
02725 { 02726 #ifndef QT_NO_SYSTEMLOCALE 02727 if (d() == systemPrivate()) { 02728 QVariant res = systemLocale()->query(format == ShortFormat 02729 ? QSystemLocale::DateFormatShort : QSystemLocale::DateFormatLong, 02730 QVariant()); 02731 if (!res.isNull()) 02732 return res.toString(); 02733 } 02734 #endif 02735 02736 const quint32 idx = 02737 format == ShortFormat 02738 ? d()->m_short_date_format_idx 02739 : d()->m_long_date_format_idx; 02740 return QString::fromUtf8(date_format_data + idx); 02741 }
Here is the call graph for this function:

| QString QLocale::timeFormat | ( | FormatType | format = LongFormat |
) | const |
If format is ShortFormat the format will be a short version. Otherwise it uses a longer version.
Definition at line 2754 of file qlocale.cpp.
References d(), QString::fromUtf8(), QVariant::isNull(), QLocalePrivate::m_long_time_format_idx, QLocalePrivate::m_short_time_format_idx, QSystemLocale::query(), ShortFormat, systemLocale(), systemPrivate(), time_format_data, QSystemLocale::TimeFormatLong, QSystemLocale::TimeFormatShort, and QVariant::toString().
Referenced by QDateTimeEditPrivate::readLocaleSettings(), and toString().
02755 { 02756 #ifndef QT_NO_SYSTEMLOCALE 02757 if (d() == systemPrivate()) { 02758 QVariant res = systemLocale()->query(format == ShortFormat 02759 ? QSystemLocale::TimeFormatShort : QSystemLocale::TimeFormatLong, 02760 QVariant()); 02761 if (!res.isNull()) 02762 return res.toString(); 02763 } 02764 #endif 02765 02766 const quint32 idx 02767 = format == ShortFormat 02768 ? d()->m_short_time_format_idx 02769 : d()->m_long_time_format_idx; 02770 return QString::fromUtf8(time_format_data + idx); 02771 }
Here is the call graph for this function:

| QChar QLocale::decimalPoint | ( | ) | const |
Definition at line 2778 of file qlocale.cpp.
References d(), and QLocalePrivate::decimal().
Here is the call graph for this function:

| QChar QLocale::groupSeparator | ( | ) | const |
Definition at line 2788 of file qlocale.cpp.
References d(), and QLocalePrivate::group().
Here is the call graph for this function:

| QChar QLocale::percent | ( | ) | const |
Definition at line 2798 of file qlocale.cpp.
References d(), and QLocalePrivate::percent().
Here is the call graph for this function:

| QChar QLocale::zeroDigit | ( | ) | const |
Definition at line 2808 of file qlocale.cpp.
References d(), and QLocalePrivate::zero().
Here is the call graph for this function:

| QChar QLocale::negativeSign | ( | ) | const |
Definition at line 2818 of file qlocale.cpp.
References d(), and QLocalePrivate::minus().
Here is the call graph for this function:

| QChar QLocale::exponential | ( | ) | const |
Definition at line 2828 of file qlocale.cpp.
References d(), and QLocalePrivate::exponential().
02829 { 02830 return d()->exponential(); 02831 }
Here is the call graph for this function:

| QString QLocale::monthName | ( | int | month, | |
| FormatType | type = LongFormat | |||
| ) | const |
Definition at line 2915 of file qlocale.cpp.
References d(), getLocaleListData(), QVariant::isNull(), LongFormat, QLocalePrivate::m_long_month_names_idx, QLocalePrivate::m_short_month_names_idx, QSystemLocale::MonthNameLong, QSystemLocale::MonthNameShort, months_data, QString, QSystemLocale::query(), ShortFormat, systemLocale(), systemPrivate(), and QVariant::toString().
Referenced by QDate::longMonthName(), QDate::shortMonthName(), and toString().
02916 { 02917 if (month < 1 || month > 12) 02918 return QString(); 02919 02920 #ifndef QT_NO_SYSTEMLOCALE 02921 if (d() == systemPrivate()) { 02922 QVariant res = systemLocale()->query(type == LongFormat 02923 ? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort, 02924 month); 02925 if (!res.isNull()) 02926 return res.toString(); 02927 } 02928 #endif 02929 02930 quint32 idx = (type == QLocale::ShortFormat) ? d()->m_short_month_names_idx : d()->m_long_month_names_idx; 02931 return getLocaleListData(months_data + idx, month - 1); 02932 }
Here is the call graph for this function:

| QString QLocale::dayName | ( | int | day, | |
| FormatType | type = LongFormat | |||
| ) | const |
Definition at line 2942 of file qlocale.cpp.
References d(), QSystemLocale::DayNameLong, QSystemLocale::DayNameShort, days_data, getLocaleListData(), QVariant::isNull(), LongFormat, QLocalePrivate::m_long_day_names_idx, QLocalePrivate::m_short_day_names_idx, QString, QSystemLocale::query(), ShortFormat, systemLocale(), systemPrivate(), and QVariant::toString().
Referenced by QDate::longDayName(), QDate::shortDayName(), and toString().
02943 { 02944 if (day < 1 || day > 7) 02945 return QString(); 02946 02947 #ifndef QT_NO_SYSTEMLOCALE 02948 if (d() == systemPrivate()) { 02949 QVariant res = systemLocale()->query(type == LongFormat 02950 ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort, 02951 day); 02952 if (!res.isNull()) 02953 return res.toString(); 02954 } 02955 #endif 02956 if (day == 7) 02957 day = 0; 02958 02959 quint32 idx = (type == QLocale::ShortFormat) ? d()->m_short_day_names_idx : d()->m_long_day_names_idx; 02960 return getLocaleListData(days_data + idx, day); 02961 }
Here is the call graph for this function:

| bool QLocale::operator== | ( | const QLocale & | other | ) | const [inline] |
| bool QLocale::operator!= | ( | const QLocale & | other | ) | const [inline] |
Returns a QString containing the name of language.
Definition at line 2107 of file qlocale.cpp.
References language_name_index, language_name_list, and LastLanguage.
Referenced by TranslationSettingsDialog::TranslationSettingsDialog().
02108 { 02109 if (uint(language) > uint(QLocale::LastLanguage)) 02110 return QLatin1String("Unknown"); 02111 return QLatin1String(language_name_list + language_name_index[language]); 02112 }
Returns a QString containing the name of country.
Definition at line 2120 of file qlocale.cpp.
References country_name_index, country_name_list, and LastCountry.
Referenced by TranslationSettingsDialog::TranslationSettingsDialog().
02121 { 02122 if (uint(country) > uint(QLocale::LastCountry)) 02123 return QLatin1String("Unknown"); 02124 return QLatin1String(country_name_list + country_name_index[country]); 02125 }
| void QLocale::setDefault | ( | const QLocale & | locale | ) | [static] |
Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.
Definition at line 2048 of file qlocale.cpp.
References d(), and default_lp.
02049 { 02050 default_lp = locale.d(); 02051 }
Here is the call graph for this function:

| QLocale QLocale::c | ( | ) | [inline, static] |
Returns a QLocale object initialized to the "C" locale.
Definition at line 497 of file qlocale.h.
References C.
Referenced by QKeyMapperPrivate::clearMappings(), getLocaleAndDirection(), RCCResourceLibrary::interpretResourceFile(), QApplication::keyboardInputLocale(), name(), and toString().
| QLocale QLocale::system | ( | ) | [static] |
Returns a QLocale object initialized to the system locale.
On Windows and Mac, this locale will use system functions to format dates and strings. It will therefore reflect customizations made by the user in the control panel.
Definition at line 2900 of file qlocale.cpp.
References C, setDataPointer(), systemPrivate(), and v.
Referenced by QDesigner::initialize(), MessageModel::load(), QDate::longDayName(), QDate::longMonthName(), main(), QDate::shortDayName(), QDate::shortMonthName(), QDate::toString(), and QTime::toString().
02901 { 02902 QLocale result(C); 02903 setDataPointer(&result.v, systemPrivate()); 02904 return result; 02905 }
Here is the call graph for this function:

| void QLocale::setNumberOptions | ( | NumberOptions | options | ) |
Definition at line 2015 of file qlocale.cpp.
References v.
Referenced by QLocale().
02016 { 02017 ::setNumberOptions(&v, options); 02018 }
| QLocale::NumberOptions QLocale::numberOptions | ( | ) | const |
By default, no options are set for the standard locales.
Definition at line 2028 of file qlocale.cpp.
References v.
Referenced by toDouble(), toLongLong(), toString(), and toULongLong().
02029 { 02030 return static_cast<NumberOption>(::numberOptions(v)); 02031 }
| const QLocalePrivate * QLocale::d | ( | ) | const [private] |
Definition at line 1993 of file qlocale.cpp.
References dataPointer(), and v.
Referenced by QString::arg(), country(), dateFormat(), dayName(), decimalPoint(), exponential(), groupSeparator(), language(), monthName(), negativeSign(), operator!=(), operator==(), percent(), QLocale(), setDefault(), QString::setNum(), QByteArray::setNum(), timeFormat(), toDouble(), QString::toDouble(), toFloat(), toLongLong(), QString::toLongLong(), toString(), toULongLong(), QString::toULongLong(), QLocalePrivate::updateSystemPrivate(), QString::vsprintf(), and zeroDigit().
01994 { 01995 return ::dataPointer(v); 01996 }
Here is the call graph for this function:

friend class QString [friend] |
friend class QByteArray [friend] |
friend struct QLocalePrivate [friend] |
void* QLocale::v [private] |
Definition at line 507 of file qlocale.h.
Referenced by d(), numberOptions(), operator=(), QLocale(), setNumberOptions(), system(), toDouble(), toLongLong(), toString(), and toULongLong().
1.5.1