CopperSpice API  1.9.2

Formats data based on a given language or country. More...

Public Typedefs

using NumberOptions = QFlags< NumberOption >
 

Public Types

enum  Country
 
enum  CurrencySymbolFormat
 
enum  FormatType
 
enum  Language
 
enum  MeasurementSystem
 
enum  NumberOption
 
enum  QuotationStyle
 
enum  Script
 

Public Methods

 QLocale ()
 
 QLocale (const QLocale &other)
 
 QLocale (const QString &name)
 
 QLocale (Language language, Country country)
 
 QLocale (Language language, Script script=Script::AnyScript, Country country=Country::AnyCountry)
 
 QLocale (QLocale &&other)
 
QString amText () const
 
QString bcp47Name () const
 
Country country () const
 
QString createSeparatedList (const QStringList &list) const
 
QString currencySymbol (CurrencySymbolFormat symbolFormat=CurrencySymbol) const
 
QString dateFormat (FormatType formatType=LongFormat) const
 
QString dateTimeFormat (FormatType formatType=LongFormat) const
 
QString dayName (int day, FormatType formatType=LongFormat) const
 
QChar decimalPoint () const
 
QChar exponential () const
 
Qt::DayOfWeek firstDayOfWeek () const
 
QChar groupSeparator () const
 
Language language () const
 
MeasurementSystem measurementSystem () const
 
QString monthName (int month, FormatType formatType=LongFormat) const
 
QString name () const
 
QString nativeCountryName () const
 
QString nativeLanguageName () const
 
QChar negativeSign () const
 
NumberOptions numberOptions () const
 
bool operator!= (const QLocale &other) const
 
QLocale & operator= (const QLocale &other)
 
QLocale & operator= (QLocale &&other)
 
bool operator== (const QLocale &other) const
 
QChar percent () const
 
QString pmText () const
 
QChar positiveSign () const
 
QString quoteString (const QString &str, QuotationStyle style=StandardQuotation) const
 
QString quoteString (QStringView str, QuotationStyle style=StandardQuotation) const
 
Script script () const
 
void setNumberOptions (NumberOptions options)
 
QString standaloneDayName (int day, FormatType formatType=LongFormat) const
 
QString standaloneMonthName (int month, FormatType formatType=LongFormat) const
 
Qt::LayoutDirection textDirection () const
 
QString timeFormat (FormatType formatType=LongFormat) const
 
QString toCurrencyString (double value, const QString &symbol=QString ()) const
 
QString toCurrencyString (float value, const QString &symbol=QString ()) const
 
QString toCurrencyString (int value, const QString &symbol=QString ()) const
 
QString toCurrencyString (qint64 value, const QString &symbol=QString ()) const
 
QString toCurrencyString (quint64 value, const QString &symbol=QString ()) const
 
QString toCurrencyString (short value, const QString &symbol=QString ()) const
 
QString toCurrencyString (uint value, const QString &symbol=QString ()) const
 
QString toCurrencyString (ushort value, const QString &symbol=QString ()) const
 
QDate toDate (const QString &string, const QString &format) const
 
QDate toDate (const QString &string, FormatType formatType=LongFormat) const
 
QDateTime toDateTime (const QString &string, const QString &format) const
 
QDateTime toDateTime (const QString &string, FormatType formatType=LongFormat) const
 
double toDouble (const QString &s, bool *ok=nullptr) const
 
float toFloat (const QString &s, bool *ok=nullptr) const
 
int toInt (const QString &s, bool *ok=nullptr, int base=0) const
 
qint64 toLongLong (const QString &s, bool *ok=nullptr, int base=0) const
 
QString toLower (const QString &str) const
 
short toShort (const QString &s, bool *ok=nullptr, int base=0) const
 
QString toString (const QDate &date, const QString &format) const
 
QString toString (const QDate &date, FormatType formatType=LongFormat) const
 
QString toString (const QDateTime &dateTime, const QString &format) const
 
QString toString (const QDateTime &dateTime, FormatType formatType=LongFormat) const
 
QString toString (const QTime &time, const QString &format) const
 
QString toString (const QTime &time, FormatType formatType=LongFormat) const
 
QString toString (double value, char f= 'g', int prec=6) const
 
QString toString (float value, char f= 'g', int prec=6) const
 
QString toString (int value) const
 
QString toString (qint64 value) const
 
QString toString (quint64 value) const
 
QString toString (short value) const
 
QString toString (uint value) const
 
QString toString (ushort value) const
 
QTime toTime (const QString &string, const QString &format) const
 
QTime toTime (const QString &string, FormatType formatType=LongFormat) const
 
uint toUInt (const QString &s, bool *ok=nullptr, int base=0) const
 
quint64 toULongLong (const QString &s, bool *ok=nullptr, int base=0) const
 
QString toUpper (const QString &str) const
 
ushort toUShort (const QString &s, bool *ok=nullptr, int base=0) const
 
QStringList uiLanguages () const
 
QList< Qt::DayOfWeekweekdays () const
 
QChar zeroDigit () const
 

Static Public Methods

static QLocale c ()
 
static QString countryToString (Country country)
 
static QString languageToString (Language language)
 
static QList< QLocale > matchingLocales (QLocale::Language language, QLocale::Script script, QLocale::Country country)
 
static QString scriptToString (Script script)
 
static void setDefault (const QLocale &locale)
 
static QLocale system ()
 

Friends

class QByteArray
 
class QIntValidator
 
class QTextStream
 

Detailed Description

The QLocale class is used to format data based on a given language or country. The displayed formatting for fields like a calendar date, time, currency, and number separators can be set based on a given region of the world by calling methods in this class.

For example, the method currencySymbol() returns the appropriate string for the specified locale. In the United States the value will be "$" and in European countries which use the euro, the symbol will be "€".

In the following example the locale is set to the language of Arabic as used in Egypt. Various strings and numbers are formatted based on the rules of this region.

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 is constructed with the default constructor it will use the default locale settings
  • QString8::toInteger(), QString::toDouble(), etc., interpret the string according to the default locale, if this fails these methods use the "C" locale
  • QString8::formatArg() uses the default locale to format a number when its position specifier in the format string contains an 'L'

Using QLocale

When a language/country pair is passed to the constructor one of three things can happen.

  • When the language/country pair is found the matching locale is used
  • When the language is found but the country is not the language is used with the most appropriate available country
  • If neither the language nor the country are found the default locale is used

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

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").formatArg(12345).formatArg(12345).formatArg(12345, 0, 16); // str == "12345 12,345 3039"

An alternative method for constructing a QLocale object is to specify the locale name. The following constructor converts the locale name to a language/country pair, it does not use the system locale database.

QLocale korean("ko");
QLocale swiss("de_CH");
See also
QString8::formatArg(), QString8::toInteger(), QString8::toDouble(), QInputMethod::locale()

Member Typedef Documentation

Typedef for QFlags<NumberOptions> which contains an OR combination of NumberOption values.

Refer to QLocale::NumberOption for the enum documentation.

Member Enumeration Documentation

This enumerated type is used to specify a country.

ConstantValue
QLocale::AnyCountry 0
QLocale::Afghanistan 1
QLocale::AlandIslands 2
QLocale::Albania 3
QLocale::Algeria 4
QLocale::AmericanSamoa 5
QLocale::Andorra 6
QLocale::Angola 7
QLocale::Anguilla 8
QLocale::Antarctica 9
QLocale::AntiguaAndBarbuda 10
QLocale::Argentina 11
QLocale::Armenia 12
QLocale::Aruba 13
QLocale::AscensionIsland 14
QLocale::Australia 15
QLocale::Austria 16
QLocale::Azerbaijan 17
QLocale::Bahamas 18
QLocale::Bahrain 19
QLocale::Bangladesh 20
QLocale::Barbados 21
QLocale::Belarus 22
QLocale::Belgium 23
QLocale::Belize 24
QLocale::Benin 25
QLocale::Bermuda 26
QLocale::Bhutan 27
QLocale::Bolivia 28
QLocale::Bonaire Use CaribbeanNetherlands
QLocale::BosniaAndHerzegowina 29
QLocale::Botswana 30
QLocale::BouvetIsland 31
QLocale::Brazil 32
QLocale::BritishIndianOceanTerritory 33
QLocale::BritishVirginIslands 34
QLocale::Brunei 35
QLocale::Bulgaria 36
QLocale::BurkinaFaso 37
QLocale::Burundi 38
QLocale::Cambodia 39
QLocale::Cameroon 40
QLocale::Canada 41
QLocale::CanaryIslands 42
QLocale::CapeVerde 43
QLocale::CaribbeanNetherlands 44
QLocale::CaymanIslands 45
QLocale::CentralAfricanRepublic 46
QLocale::CeutaAndMelilla 47
QLocale::Chad 48
QLocale::Chile 49
QLocale::China 50
QLocale::ChristmasIsland 51
QLocale::ClippertonIsland 52
QLocale::CocosIslands 53
QLocale::Colombia 54
QLocale::Comoros 55
QLocale::CongoBrazzaville 56
QLocale::CongoKinshasa 57
QLocale::CookIslands 58
QLocale::CostaRica 59
QLocale::Croatia 60
QLocale::Cuba 61
QLocale::CuraSao Use Curacao
QLocale::Curacao 62
QLocale::Cyprus 63
QLocale::CzechRepublic Use Czechia
QLocale::Czechia 64
QLocale::DemocraticRepublicOfCongo Use CongoKinshasa
QLocale::DemocraticRepublicOfKorea Use NorthKorea
QLocale::Denmark 65
QLocale::DiegoGarcia 66
QLocale::Djibouti 67
QLocale::Dominica 68
QLocale::DominicanRepublic 69
QLocale::EastTimor Use TimorLeste
QLocale::Ecuador 70
QLocale::Egypt 71
QLocale::ElSalvador 72
QLocale::EquatorialGuinea 73
QLocale::Eritrea 74
QLocale::Estonia 75
QLocale::Eswatini 76
QLocale::Ethiopia 77
QLocale::FalklandIslands 78
QLocale::FaroeIslands 79
QLocale::Fiji 80
QLocale::Finland 81
QLocale::France 82
QLocale::FrenchGuiana 83
QLocale::FrenchPolynesia 84
QLocale::FrenchSouthernTerritories 85
QLocale::Gabon 86
QLocale::Gambia 87
QLocale::Georgia 88
QLocale::Germany 89
QLocale::Ghana 90
QLocale::Gibraltar 91
QLocale::Greece 92
QLocale::Greenland 93
QLocale::Grenada 94
QLocale::Guadeloupe 95
QLocale::Guam 96
QLocale::Guatemala 97
QLocale::Guernsey 98
QLocale::Guinea 99
QLocale::GuineaBissau 100
QLocale::Guyana 101
QLocale::Haiti 102
QLocale::HeardAndMcDonaldIslands 103
QLocale::Honduras 104
QLocale::HongKong 105
QLocale::Hungary 106
QLocale::Iceland 107
QLocale::India 108
QLocale::Indonesia 109
QLocale::Iran 110
QLocale::Iraq 111
QLocale::Ireland 112
QLocale::IsleOfMan 113
QLocale::Israel 114
QLocale::Italy 115
QLocale::IvoryCoast 116
QLocale::Jamaica 117
QLocale::Japan 118
QLocale::Jersey 119
QLocale::Jordan 120
QLocale::Kazakhstan 121
QLocale::Kenya 122
QLocale::Kiribati 123
QLocale::Kosovo 124
QLocale::Kuwait 125
QLocale::Kyrgyzstan 126
QLocale::Laos 127
QLocale::Latvia 128
QLocale::Lebanon 129
QLocale::Lesotho 130
QLocale::Liberia 131
QLocale::Libya 132
QLocale::Liechtenstein 133
QLocale::Lithuania 134
QLocale::Luxembourg 135
QLocale::Macao 136
QLocale::Macau Use Macao
QLocale::Macedonia Use NorthMacedonia
QLocale::Madagascar 137
QLocale::Malawi 138
QLocale::Malaysia 139
QLocale::Maldives 140
QLocale::Mali 141
QLocale::Malta 142
QLocale::MarshallIslands 143
QLocale::Martinique 144
QLocale::Mauritania 145
QLocale::Mauritius 146
QLocale::Mayotte 147
QLocale::Mexico 148
QLocale::Micronesia 149
QLocale::Moldova 150
QLocale::Monaco 151
QLocale::Mongolia 152
QLocale::Montenegro 153
QLocale::Montserrat 154
QLocale::Morocco 155
QLocale::Mozambique 156
QLocale::Myanmar 157
QLocale::Namibia 158
QLocale::Nauru 159
QLocale::Nepal 160
QLocale::Netherlands 161
QLocale::NewCaledonia 162
QLocale::NewZealand 163
QLocale::Nicaragua 164
QLocale::Niger 165
QLocale::Nigeria 166
QLocale::Niue 167
QLocale::NorfolkIsland 168
QLocale::NorthKorea 169
QLocale::NorthMacedonia 170
QLocale::NorthernMarianaIslands 171
QLocale::Norway 172
QLocale::Oman 173
QLocale::Pakistan 174
QLocale::Palau 175
QLocale::PalestinianTerritories 176
QLocale::Panama 177
QLocale::PapuaNewGuinea 178
QLocale::Paraguay 179
QLocale::PeoplesRepublicOfCongo Use CongoBrazzaville
QLocale::Peru 180
QLocale::Philippines 181
QLocale::Pitcairn 182
QLocale::Poland 183
QLocale::Portugal 184
QLocale::PuertoRico 185
QLocale::Qatar 186
QLocale::RepublicOfKorea Use SouthKorea
QLocale::Reunion 187
QLocale::Romania 188
QLocale::Russia 189
QLocale::RussianFederation Use Russia
QLocale::Rwanda 190
QLocale::Samoa 191
QLocale::SanMarino 192
QLocale::SaoTomeAndPrincipe 193
QLocale::SaudiArabia 194
QLocale::Senegal 195
QLocale::Serbia 196
QLocale::Seychelles 197
QLocale::SierraLeone 198
QLocale::Singapore 199
QLocale::SintMaarten 200
QLocale::Slovakia 201
QLocale::Slovenia 202
QLocale::SolomonIslands 203
QLocale::Somalia 204
QLocale::SouthAfrica 205
QLocale::SouthGeorgiaAndSouthSandwichIslands 206
QLocale::SouthKorea 207
QLocale::SouthSudan 208
QLocale::Spain 209
QLocale::SriLanka 210
QLocale::SaintBarthelemy 211
QLocale::SaintHelena 212
QLocale::SaintKittsAndNevis 213
QLocale::SaintLucia 214
QLocale::SaintMartin 215
QLocale::SaintPierreAndMiquelon 216
QLocale::SaintVincentAndGrenadines 217
QLocale::Sudan 218
QLocale::Suriname 219
QLocale::SvalbardAndJanMayen 220
QLocale::Swaziland Use Eswatini
QLocale::Sweden 221
QLocale::Switzerland 222
QLocale::Syria 223
QLocale::SyrianArabRepublic Use Syria
QLocale::Taiwan 224
QLocale::Tajikistan 225
QLocale::Tanzania 226
QLocale::Thailand 227
QLocale::TimorLeste 228
QLocale::Togo 229
QLocale::Tokelau 230
QLocale::Tonga 231
QLocale::TrinidadAndTobago 232
QLocale::TristanDaCunha 233
QLocale::Tunisia 234
QLocale::Turkey 235
QLocale::Turkmenistan 236
QLocale::TurksAndCaicosIslands 237
QLocale::Tuvalu 238
QLocale::Uganda 239
QLocale::Ukraine 240
QLocale::UnitedArabEmirates 241
QLocale::UnitedKingdom 242
QLocale::UnitedStates 243
QLocale::UnitedStatesMinorOutlyingIslands Use UnitedStatesOutlyingIslands
QLocale::UnitedStatesOutlyingIslands 244
QLocale::UnitedStatesVirginIslands 245
QLocale::Uruguay 246
QLocale::Uzbekistan 247
QLocale::Vanuatu 248
QLocale::VaticanCity 249
QLocale::VaticanCityState Use VaticanCity
QLocale::Venezuela 250
QLocale::Vietnam 251
QLocale::WallisAndFutuna 252
QLocale::WallisAndFutunaIslands Use WallisAndFutuna
QLocale::WesternSahara 253
QLocale::World 254
QLocale::Yemen 255
QLocale::Zambia 256
QLocale::Zimbabwe 257
See also
country(), countryToString()

Specifies the format of the currency symbol.

ConstantValueDescription
QLocale::CurrencyIsoCode0 ISO-4217 code of the currency
QLocale::CurrencySymbol1 Currency symbol
QLocale::CurrencyDisplayName2 User readable name of the currency

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

ConstantValueDescription
QLocale::LongFormat0 Long version of day and month names ("January" or "February")
QLocale::ShortFormat1 Short version of day and month names ("Jan" or "Feb")
QLocale::NarrowFormat2 Special version of day and month names for use when space is limited; for example, returning "J" as a month name. The narrow format might contain the same text for different months and days or it can even be an empty string if the locale does not support narrow names, so you should avoid using it for date formatting. Also, for the system locale this format is the same as ShortFormat.

This enumerated type is used to specify a language.

ConstantValueDescription
QLocale::AnyLanguage 0  
QLocale::C 1 Refer to QLocale::c()
QLocale::Abaza 2  
QLocale::Abkhazian 3  
QLocale::Afan Use Oromo  
QLocale::Afar 4  
QLocale::Afrikaans 5  
QLocale::Aghem 6  
QLocale::Akan 7  
QLocale::Akkadian 8  
QLocale::Akoose 9  
QLocale::Albanian 10  
QLocale::AmericanSignLanguage 11  
QLocale::Amharic 12  
QLocale::AncientNorthArabian 13  
QLocale::AncientEgyptian 14  
QLocale::AncientGreek 15  
QLocale::Arabic 16  
QLocale::Aragonese 17  
QLocale::Aramaic 18  
QLocale::Armenian 19  
QLocale::Assamese 20  
QLocale::Asturian 21  
QLocale::Asu 22  
QLocale::Atsam 23  
QLocale::Avaric 24  
QLocale::Avestan 25  
QLocale::Aymara 26  
QLocale::Azerbaijani 27  
QLocale::Bafia 28  
QLocale::Balinese 29  
QLocale::Baluchi 30  
QLocale::Bambara 31  
QLocale::Bamun 32  
QLocale::Bangla 33  
QLocale::Basaa 34  
QLocale::Bashkir 35  
QLocale::Basque 36  
QLocale::BatakToba 37  
QLocale::Belarusian 38  
QLocale::Bemba 39  
QLocale::Bena 40  
QLocale::Bengali Use Bangla  
QLocale::Bhojpuri 41  
QLocale::Bhutani Use Dzongkha  
QLocale::Bislama 42  
QLocale::Blin 43  
QLocale::Bodo 44  
QLocale::Bosnian 45  
QLocale::Breton 46  
QLocale::Buginese 47  
QLocale::Buhid 48  
QLocale::Bulgarian 49  
QLocale::Burmese 50  
QLocale::Byelorussian Use Belarusian  
QLocale::Cambodian Use Khmer  
QLocale::Cantonese 51  
QLocale::Carian 52  
QLocale::Catalan 53  
QLocale::Cebuano 54  
QLocale::CentralAtlasTamazight 55  
QLocale::CentralKurdish 56  
QLocale::Chakma 57  
QLocale::Chamorro 58  
QLocale::Chechen 59  
QLocale::Cherokee 60  
QLocale::Chewa Use Nyanja  
QLocale::Chickasaw 61  
QLocale::Chiga 62  
QLocale::Chinese 63  
QLocale::Church 64  
QLocale::Chuvash 65  
QLocale::ClassicalMandaic 66  
QLocale::Colognian 67  
QLocale::Coptic 68  
QLocale::Cornish 69  
QLocale::Corsican 70  
QLocale::Cree 71  
QLocale::Croatian 72  
QLocale::Czech 73  
QLocale::Danish 74  
QLocale::Divehi 75  
QLocale::Dogri 76  
QLocale::Duala 77  
QLocale::Dutch 78  
QLocale::Dzongkha 79  
QLocale::EasternCham 80  
QLocale::EasternKayah 81  
QLocale::Embu 82  
QLocale::English 83  
QLocale::Erzya 84  
QLocale::Esperanto 85  
QLocale::Estonian 86  
QLocale::Etruscan 87  
QLocale::Ewe 88  
QLocale::Ewondo 89  
QLocale::Faroese 90  
QLocale::Fijian 91  
QLocale::Filipino 92  
QLocale::Finnish 93  
QLocale::French 94  
QLocale::Frisian Use WesternFrisian  
QLocale::Friulian 95  
QLocale::Fulah 96  
QLocale::Ga 97  
QLocale::Gaelic 98  
QLocale::Galician 99  
QLocale::Ganda 100  
QLocale::Geez 101  
QLocale::Georgian 102  
QLocale::German 103  
QLocale::Gothic 104  
QLocale::Greek 105  
QLocale::Greenlandic Use Kalaallisut  
QLocale::Guarani 106  
QLocale::Gujarati 107  
QLocale::Gusii 108  
QLocale::Haitian 109  
QLocale::Hanunoo 110  
QLocale::Haryanvi 111  
QLocale::Hausa 112  
QLocale::Hawaiian 113  
QLocale::Hebrew 114  
QLocale::Herero 115  
QLocale::Hindi 116  
QLocale::HiriMotu 117  
QLocale::HmongNjua 118  
QLocale::Ho 119  
QLocale::Hungarian 120  
QLocale::Icelandic 121  
QLocale::Ido 122  
QLocale::Igbo 123  
QLocale::InariSami 124  
QLocale::Indonesian 125  
QLocale::Ingush 126  
QLocale::Interlingua 127  
QLocale::Interlingue 128  
QLocale::Inuktitut 129  
QLocale::Inupiak Use Inupiaq  
QLocale::Inupiaq 130  
QLocale::Irish 131  
QLocale::Italian 132  
QLocale::Japanese 133  
QLocale::Javanese 134  
QLocale::Jju 135  
QLocale::JolaFonyi 136  
QLocale::Kabuverdianu 137  
QLocale::Kabyle 138  
QLocale::Kaingang 139  
QLocale::Kako 140  
QLocale::Kalaallisut 141  
QLocale::Kalenjin 142  
QLocale::Kamba 143  
QLocale::Kannada 144  
QLocale::Kanuri 145  
QLocale::Kashmiri 146  
QLocale::Kazakh 147  
QLocale::Kenyang 148  
QLocale::Khmer 149  
QLocale::Kiche 150  
QLocale::Kikuyu 151  
QLocale::Kinyarwanda 152  
QLocale::Komi 153  
QLocale::Kongo 154  
QLocale::Konkani 155  
QLocale::Korean 156  
QLocale::Koro 157  
QLocale::KoyraChiini 158  
QLocale::KoyraboroSenni 159  
QLocale::Kpelle 160  
QLocale::Kuanyama 161  
QLocale::Kurdish 162  
QLocale::Kurundi Use Rundi  
QLocale::Kwasio 163  
QLocale::Kyrgyz 164  
QLocale::Lakota 165  
QLocale::Langi 166  
QLocale::Lao 167  
QLocale::LargeFloweryMiao 168  
QLocale::Latin 169  
QLocale::Latvian 170  
QLocale::Lepcha 171  
QLocale::Lezghian 172  
QLocale::Ligurian 173  
QLocale::Limbu 174  
QLocale::Limburgish 175  
QLocale::LinearA 176  
QLocale::Lingala 177  
QLocale::Lisu 178  
QLocale::LiteraryChinese 179  
QLocale::Lithuanian 180  
QLocale::Lojban 181  
QLocale::LowGerman 182  
QLocale::LowerSorbian 183  
QLocale::Lu 184  
QLocale::LubaKatanga 185  
QLocale::LuleSami 186  
QLocale::Luo 187  
QLocale::Luxembourgish 188  
QLocale::Luyia 189  
QLocale::Lycian 190  
QLocale::Lydian 191  
QLocale::Macedonian 192  
QLocale::Machame 193  
QLocale::Maithili 194  
QLocale::MakhuwaMeetto 195  
QLocale::Makonde 196  
QLocale::Malagasy 197  
QLocale::Malay 198  
QLocale::Malayalam 199  
QLocale::Maltese 200  
QLocale::Mandingo 201  
QLocale::ManichaeanMiddlePersian 202  
QLocale::Manipuri 203  
QLocale::Manx 204  
QLocale::Maori 205  
QLocale::Mapuche 206  
QLocale::Marathi 207  
QLocale::Marshallese 208  
QLocale::Masai 209  
QLocale::Mazanderani 210  
QLocale::Mende 211  
QLocale::Meroitic 212  
QLocale::Meru 213  
QLocale::Meta 214  
QLocale::Mohawk 215  
QLocale::Moksha 216  
QLocale::Mongolian 217  
QLocale::Morisyen 218  
QLocale::Mundang 219  
QLocale::Muscogee 220  
QLocale::Nama 221  
QLocale::Nauru 222  
QLocale::Navaho Use Navajo  
QLocale::Navajo 223  
QLocale::Ndonga 224  
QLocale::Nepali 225  
QLocale::Newari 226  
QLocale::Ngiemboon 227  
QLocale::Ngomba 228  
QLocale::Nheengatu 229  
QLocale::NigerianPidgin 230  
QLocale::Nko 231  
QLocale::NorthNdebele 232  
QLocale::NorthernFrisian 233  
QLocale::NorthernLuri 234  
QLocale::NorthernSami 235  
QLocale::NorthernSotho 236  
QLocale::NorthernThai 237  
QLocale::NorwegianBokmal 238  
QLocale::NorwegianNynorsk 239  
QLocale::Nuer 240  
QLocale::Nyanja 241  
QLocale::Nyankole 242  
QLocale::Obolo 243  
QLocale::Occitan 244  
QLocale::Odia 245  
QLocale::Ojibwa 246  
QLocale::OldIrish 247  
QLocale::OldNorse 248  
QLocale::OldPersian 249  
QLocale::OldTurkish 250  
QLocale::Oromo 251  
QLocale::Osage 252  
QLocale::Ossetic 253  
QLocale::Pahlavi 254  
QLocale::Palauan 255  
QLocale::Pali 256  
QLocale::Papiamento 257  
QLocale::Parthian 258  
QLocale::Pashto 259  
QLocale::Persian 260  
QLocale::Phoenician 261  
QLocale::Pijin 262  
QLocale::Polish 263  
QLocale::Portuguese 264  
QLocale::Prussian 265  
QLocale::Punjabi 266  
QLocale::Quechua 267  
QLocale::Rajasthani 268  
QLocale::Rejang 269  
QLocale::RhaetoRomance Use Romansh  
QLocale::Rohingya 270  
QLocale::Romanian 271  
QLocale::Romansh 272  
QLocale::Rombo 273  
QLocale::Rundi 274  
QLocale::Russian 275  
QLocale::Rwa 276  
QLocale::Sabaean 277  
QLocale::Saho 278  
QLocale::Sakha 279  
QLocale::Samaritan 280  
QLocale::Samburu 281  
QLocale::Samoan 282  
QLocale::Sango 283  
QLocale::Sangu 284  
QLocale::Sanskrit 285  
QLocale::Santali 286  
QLocale::Sardinian 287  
QLocale::Saurashtra 288  
QLocale::Sena 289  
QLocale::Serbian 290  
QLocale::Shambala 291  
QLocale::Shona 292  
QLocale::SichuanYi 293  
QLocale::Sicilian 294  
QLocale::Sidamo 295  
QLocale::Silesian 296  
QLocale::Sindhi 297  
QLocale::Sinhala 298  
QLocale::SkoltSami 299  
QLocale::Slovak 300  
QLocale::Slovenian 301  
QLocale::Soga 302  
QLocale::Somali 303  
QLocale::Sora 304  
QLocale::SouthNdebele 305  
QLocale::SouthernKurdish 306  
QLocale::SouthernSami 307  
QLocale::SouthernSotho 308  
QLocale::Spanish 309  
QLocale::StandardMoroccanTamazight 310  
QLocale::Sundanese 311  
QLocale::Swahili 312  
QLocale::Swati 313  
QLocale::Swedish 314  
QLocale::SwissGerman 315  
QLocale::Sylheti 316  
QLocale::Syriac 317  
QLocale::Tachelhit 318  
QLocale::Tagbanwa 319  
QLocale::Tahitian 320  
QLocale::TaiDam 321  
QLocale::TaiNua 322  
QLocale::Taita 323  
QLocale::Tajik 324  
QLocale::Tamil 325  
QLocale::Taroko 326  
QLocale::Tasawaq 327  
QLocale::Tatar 328  
QLocale::TedimChin 329  
QLocale::Telugu 330  
QLocale::Teso 331  
QLocale::Thai 332  
QLocale::Tibetan 333  
QLocale::Tigre 334  
QLocale::Tigrinya 335  
QLocale::TokPisin 336  
QLocale::Tokelau 337  
QLocale::TokiPona 338  
QLocale::Tongan 339  
QLocale::Torwali 340  
QLocale::Tsonga 341  
QLocale::Tswana 342  
QLocale::Turkish 343  
QLocale::Turkmen 344  
QLocale::Tuvalu 345  
QLocale::Tyap 346  
QLocale::Ugaritic 347  
QLocale::Uighur Use Uyghur  
QLocale::Uigur Use Uyghur  
QLocale::Ukrainian 348  
QLocale::UpperSorbian 349  
QLocale::Urdu 350  
QLocale::Uyghur 351  
QLocale::Uzbek 352  
QLocale::Vai 353  
QLocale::Venda 354  
QLocale::Vietnamese 355  
QLocale::Volapuk 356  
QLocale::Vunjo 357  
QLocale::Walloon 358  
QLocale::Walser 359  
QLocale::Warlpiri 360  
QLocale::Welsh 361  
QLocale::WesternBalochi 362  
QLocale::WesternFrisian 363  
QLocale::Wolaytta 364  
QLocale::Wolof 365  
QLocale::Xhosa 366  
QLocale::Yangben 367  
QLocale::Yiddish 368  
QLocale::Yoruba 369  
QLocale::Zarma 370  
QLocale::Zhuang 371  
QLocale::Zulu 372  
See also
language(), languageToString()

This enum defines which units are used for measurement.

ConstantValueDescription
QLocale::MetricSystem0 Metric units such as meters, centimeters and millimeters
QLocale::ImperialUSSystem1 Imperial units such as inches and miles as they are used in the United States
QLocale::ImperialUKSystem2 Imperial units such as inches and miles as they are used in the United Kingdom
QLocale::ImperialSystemImperialUSSystem Compatibility value, same as ImperialUSSystem

This enum defines

ConstantValueDescription
QLocale::OmitGroupSeparator0 If set, group separators will not be inserted when converting numbers to strings
QLocale::RejectGroupSeparator1 If set, group separators will be rejected when converting strings to numbers
See also
setNumberOptions(), numberOptions()

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

ConstantValueDescription
QLocale::StandardQuotation0 If set, standard quotation marks will be used to quote strings
QLocale::AlternateQuotation1 If set, alternate quotation marks will be used to quote strings
See also
quoteString()

This enumerated type is used to specify a script.

ConstantValue
QLocale::AnyScript 0
QLocale::AdlamScript 1
QLocale::AhomScript 2
QLocale::AnatolianHieroglyphsScript 3
QLocale::ArabicScript 4
QLocale::ArmenianScript 5
QLocale::AvestanScript 6
QLocale::BalineseScript 7
QLocale::BamumScript 8
QLocale::BanglaScript 9
QLocale::BassaVahScript 10
QLocale::BatakScript 11
QLocale::BengaliScript Use BanglaScript
QLocale::BhaiksukiScript 12
QLocale::BopomofoScript 13
QLocale::BrahmiScript 14
QLocale::BrailleScript 15
QLocale::BugineseScript 16
QLocale::BuhidScript 17
QLocale::CanadianAboriginalScript 18
QLocale::CarianScript 19
QLocale::CaucasianAlbanianScript 20
QLocale::ChakmaScript 21
QLocale::ChamScript 22
QLocale::CherokeeScript 23
QLocale::ChorasmianScript 24
QLocale::CopticScript 25
QLocale::CuneiformScript 26
QLocale::CypriotScript 27
QLocale::Cypro_MinoanScript 28
QLocale::CyrillicScript 29
QLocale::DeseretScript 30
QLocale::DevanagariScript 31
QLocale::Dives_AkuruScript 32
QLocale::DograScript 33
QLocale::DuployanScript 34
QLocale::EgyptianHieroglyphsScript 35
QLocale::ElbasanScript 36
QLocale::ElymaicScript 37
QLocale::EthiopicScript 38
QLocale::FraserScript 39
QLocale::GeorgianScript 40
QLocale::GlagoliticScript 41
QLocale::GothicScript 42
QLocale::GranthaScript 43
QLocale::GreekScript 44
QLocale::GujaratiScript 45
QLocale::GunjalaGondiScript 46
QLocale::GurmukhiScript 47
QLocale::HanScript 48
QLocale::HangulScript 49
QLocale::HanifiRohingyaScript 50
QLocale::HanunooScript 51
QLocale::HatranScript 52
QLocale::HebrewScript 53
QLocale::HiraganaScript 54
QLocale::ImperialAramaicScript 55
QLocale::InscriptionalPahlaviScript 56
QLocale::InscriptionalParthianScript 57
QLocale::JamoScript 58
QLocale::JapaneseScript 59
QLocale::JavaneseScript 60
QLocale::KaithiScript 61
QLocale::KannadaScript 62
QLocale::KatakanaScript 63
QLocale::KawiScript 64
QLocale::KayahLiScript 65
QLocale::KharoshthiScript 66
QLocale::KhitanSmallScript 67
QLocale::KhmerScript 68
QLocale::KhojkiScript 69
QLocale::KhudawadiScript 70
QLocale::KoreanScript 71
QLocale::LannaScript 72
QLocale::LaoScript 73
QLocale::LatinScript 74
QLocale::LepchaScript 75
QLocale::LimbuScript 76
QLocale::LinearAScript 77
QLocale::LinearBScript 78
QLocale::LycianScript 79
QLocale::LydianScript 80
QLocale::MahajaniScript 81
QLocale::MakasarScript 82
QLocale::MalayalamScript 83
QLocale::MandaeanScript 84
QLocale::ManichaeanScript 85
QLocale::MarchenScript 86
QLocale::MasaramGondiScript 87
QLocale::MedefaidrinScript 88
QLocale::MeiteiMayekScript 89
QLocale::MendeScript 90
QLocale::MendeKikakuiScript Use MendeScript
QLocale::MeroiticScript 92
QLocale::MeroiticCursiveScript 91
QLocale::ModiScript 93
QLocale::MongolianScript 94
QLocale::MroScript 95
QLocale::MultaniScript 96
QLocale::MyanmarScript 97
QLocale::NabataeanScript 98
QLocale::NagMundariScript 99
QLocale::NandinagariScript 100
QLocale::NewTaiLueScript 101
QLocale::NewaScript 102
QLocale::NkoScript 103
QLocale::NushuScript 104
QLocale::NyiakengPuachueHmongScript 105
QLocale::OdiaScript 106
QLocale::OghamScript 107
QLocale::OlChikiScript 108
QLocale::OldHungarianScript 109
QLocale::OldItalicScript 110
QLocale::OldNorthArabianScript 111
QLocale::OldPermicScript 112
QLocale::OldPersianScript 113
QLocale::OldSogdianScript 114
QLocale::OldSouthArabianScript 115
QLocale::OldUyghurScript 116
QLocale::OriyaScript Use OdiaScript
QLocale::OrkhonScript 117
QLocale::OsageScript 118
QLocale::OsmanyaScript 119
QLocale::PahawhHmongScript 120
QLocale::PalmyreneScript 121
QLocale::PauCinHauScript 122
QLocale::PhagsPaScript 123
QLocale::PhoenicianScript 124
QLocale::PollardPhoneticScript 125
QLocale::PsalterPahlaviScript 126
QLocale::RejangScript 127
QLocale::RunicScript 128
QLocale::SamaritanScript 129
QLocale::SaurashtraScript 130
QLocale::SharadaScript 131
QLocale::ShavianScript 132
QLocale::SiddhamScript 133
QLocale::SignWritingScript 134
QLocale::SimplifiedHanScript 135
QLocale::SimplifiedChineseScript Use SimplifiedHanScript
QLocale::SinhalaScript 136
QLocale::SogdianScript 137
QLocale::SoraSompengScript 138
QLocale::SoyomboScript 139
QLocale::SundaneseScript 140
QLocale::SylotiNagriScript 141
QLocale::SyriacScript 142
QLocale::TagalogScript 143
QLocale::TagbanwaScript 144
QLocale::TaiLeScript 146
QLocale::TaiVietScript 147
QLocale::TakriScript 148
QLocale::TamilScript 149
QLocale::TangsaScript 145
QLocale::TangutScript 150
QLocale::TeluguScript 151
QLocale::ThaanaScript 152
QLocale::ThaiScript 153
QLocale::TibetanScript 154
QLocale::TifinaghScript 155
QLocale::TirhutaScript 156
QLocale::TotoScript 157
QLocale::TraditionalHanScript 158
QLocale::TraditionalChineseScript Use TraditionalHanScript
QLocale::UgariticScript 159
QLocale::VaiScript 160
QLocale::VarangKshitiScript 161
QLocale::VithkuqiScript 162
QLocale::WanchoScript 163
QLocale::YezidiScript 164
QLocale::YiScript 165
QLocale::Zanabazar_SquareScript 166
See also
script(), scriptToString(), languageToString()

Constructor & Destructor Documentation

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()
QLocale::QLocale ( const QString name)

Constructs a QLocale object with the specified name using the format shown below.

  • The underscore can be replaced by a minus sign
  • If the format is invalid or the language is not a valid ISO 639 code, the "C" locale will be used
  • If country is missing or is not a valid ISO 3166 code, the most appropriate country is chosen for the specified language
  • Another option is to pass "C" for the name
"language[_script][_country][.codeset][\@modifier]"
Language
Two letter ISO 639 language code in lowercase
Script
Four letter ISO 15924 script code in titlecase
Country
Two or three letter ISO 3166 country code in uppercase
Codeset
Ignored
Modifier
Ignored

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

See also
bcp47Name()
QLocale::QLocale ( Language  language,
Country  country 
)

Constructs a QLocale object with the specified language and country. The language and country that are actually used can be queried using language() and country().

See also
setDefault(), language(), country()
QLocale::QLocale ( Language  language,
Script  script = Script::AnyScript,
Country  country = Country::AnyCountry 
)

Constructs a QLocale object with the specified language, script and country. The language, script and country that are actually used can be queried using language(), script() and country().

See also
setDefault(), language(), script(), country()
QLocale::QLocale ( const QLocale &  other)

Copy constructs a new QLocale from other.

QLocale::QLocale ( QLocale &&  other)

Move constructs a new QLocale from other.

Method Documentation

QString QLocale::amText ( ) const

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

See also
pmText()
QString QLocale::bcp47Name ( ) const

Returns the dash-separated language, script and country (and possibly other BCP47 fields) of this locale as a string. Unlike the uiLanguages() the returned value of the bcp47Name() represents the locale name of the QLocale data but not the language the user-interface should be in.

This method tries to conform the locale name to BCP47.

See also
language(), country(), script(), uiLanguages()
QLocale QLocale::c ( )
inlinestatic

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

This locale is similar to using English for the language and UnitedStates for the Country, which would be "en_US". The main difference is with "C" the number and date formatting are simplified and the sort order is case sensitive.

See also
system()
Country QLocale::country ( ) const

Returns the country of this QLocale.

See also
language(), script(), countryToString(), bcp47Name()
QString QLocale::countryToString ( Country  country)
static

Returns a QString containing the name of country.

See also
languageToString(), scriptToString(), country(), bcp47Name()
QString QLocale::createSeparatedList ( const QStringList list) const

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

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

Returns a currency symbol according to the symbolFormat.

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

Returns the date format used for the current locale. If formatType is LongFormat the format will be a long version. Otherwise it uses a shorter version.

See also
QDate::toString(), QDate::fromString()
QString QLocale::dateTimeFormat ( FormatType  formatType = LongFormat) const

Returns the date time format used for the current locale. If formatType is ShortFormat the format will be a short version, otherwise uses a longer version.

See also
QDateTime::toString(), QDateTime::fromString()
QString QLocale::dayName ( int  day,
FormatType  formatType = LongFormat 
) const

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

See also
monthName(), standaloneDayName()
QChar QLocale::decimalPoint ( ) const

Returns the decimal point character of this QLocale.

QChar QLocale::exponential ( ) const

Returns the exponential character of this QLocale.

Qt::DayOfWeek QLocale::firstDayOfWeek ( ) const

Returns the first day of the week according to this QLocale.

QChar QLocale::groupSeparator ( ) const

Returns the group separator character of this QLocale.

Language QLocale::language ( ) const

Returns the language of this QLocale.

See also
script(), country(), languageToString(), bcp47Name()
QString QLocale::languageToString ( Language  language)
static

Returns a QString containing the name of language.

See also
countryToString(), scriptToString(), bcp47Name()
QList< QLocale > QLocale::matchingLocales ( QLocale::Language  language,
QLocale::Script  script,
QLocale::Country  country 
)
static

Returns a list of valid locales which match the given language, script, and country.

// returns a list of every locale
QList<QLocale> list = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
// returns a list of every locale for Switzerland
QList<QLocale> list = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::Switzerland);
MeasurementSystem QLocale::measurementSystem ( ) const

Returns the measurement system for the locale.

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

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

See also
dayName(), standaloneMonthName()
QString QLocale::name ( ) const

Returns the language and country of this QLocale 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 or three-letter ISO 3166 country code.

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()
QString QLocale::nativeCountryName ( ) const

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

See also
nativeLanguageName(), countryToString()
QString QLocale::nativeLanguageName ( ) const

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

See also
nativeCountryName(), languageToString()
QChar QLocale::negativeSign ( ) const

Returns the negative sign character of this QLocale.

NumberOptions QLocale::numberOptions ( ) const

Returns the options related to number conversions for this QLocale. By default no options are set for the standard locales.

See also
setNumberOptions()
bool QLocale::operator!= ( const QLocale &  other) const

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

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

Copy assigns from other and returns a reference to this object.

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

Move assigns from other and returns a reference to this object.

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

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

QChar QLocale::percent ( ) const

Returns the percent character of this QLocale.

QString QLocale::pmText ( ) const

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

See also
amText()
QChar QLocale::positiveSign ( ) const

Returns the positive sign character of this QLocale.

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

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

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

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

Script QLocale::script ( ) const

Returns the script of this locale.

See also
language(), country(), languageToString(), scriptToString(), bcp47Name()
QString QLocale::scriptToString ( Script  script)
static

Returns a QString containing the name of script.

See also
languageToString(), countryToString(), script(), bcp47Name()
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.

Warning
In a multithreaded application the default locale should be set at application startup before any non-GUI threads are created. This method is not conditionally thread safe.
See also
system(), c()
void QLocale::setNumberOptions ( NumberOptions  options)

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

See also
numberOptions()
QString QLocale::standaloneDayName ( int  day,
FormatType  formatType = 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 formatType. If the locale information does not specify the standalone day name then return value is the same as in dayName().

See also
dayName(), standaloneMonthName()
QString QLocale::standaloneMonthName ( int  month,
FormatType  formatType = LongFormat 
) const

Returns the localized name of month that is used as a standalone text, in the format specified by formatType. If the locale information does not specify the standalone month name then return value is the same as in monthName().

See also
monthName(), standaloneDayName()
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()
Qt::LayoutDirection QLocale::textDirection ( ) const

Returns the text direction of the language.

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

Returns the time format used for the current locale. If formatType is LongFormat the format will be a long version. Otherwise it uses a shorter version.

See also
QTime::toString(), QTime::fromString()
QString QLocale::toCurrencyString ( double  value,
const QString symbol = QString() 
) const

This is an overloaded method.

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

This is an overloaded method.

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

This is an overloaded method.

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

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

See also
currencySymbol()
QString QLocale::toCurrencyString ( quint64  value,
const QString symbol = QString() 
) const

This is an overloaded method.

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

This is an overloaded method.

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

This is an overloaded method.

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

This is an overloaded method.

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

Parses the date string given in string and returns the date. See QDate::fromString() for information on the expressions that can be used with this function. This method 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()
QDate QLocale::toDate ( const QString string,
FormatType  formatType = LongFormat 
) const

Parses the date string given in string and returns the date. The format of the date string is chosen according to the formatType parameter. If the date could not be parsed, returns an invalid date.

See also
dateFormat(), toTime(), toDateTime(), QDate::fromString()
QDateTime QLocale::toDateTime ( const QString string,
const QString format 
) const

Parses the date/time string given in string and returns the time. See QDateTime::fromString() for information on the expressions that can be used with this method. If the string could not be parsed, returns an invalid QDateTime.

Note
The month and day names used must be given in the user's local language.
See also
dateTimeFormat(), toTime(), toDate(), QDateTime::fromString()
QDateTime QLocale::toDateTime ( const QString string,
FormatType  formatType = LongFormat 
) const

Parses the date/time string given in string and returns the time. The format of the date/time string is chosen according to the formatType parameter.

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

See also
dateTimeFormat(), toTime(), toDate(), QDateTime::fromString()
double QLocale::toDouble ( const QString s,
bool *  ok = nullptr 
) const

Returns the double represented by the localized string s. Unlike QString::toDouble() this method does not fall back to the "C" locale if the string can not be interpreted in this locale. Leading and trailing whitespace is ignored.

If the conversion fails 0.0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

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

In the last conversion the return value is 1234.0 because '.' is the thousands group separator in the German locale.

See also
toFloat(), toInt(), toString()
float QLocale::toFloat ( const QString s,
bool *  ok = nullptr 
) const

Returns the float represented by the localized string s or 0.0. Leading and trailing whitespace is ignored.

If the conversion fails 0.0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toDouble(), toInt(), toString()
int QLocale::toInt ( const QString s,
bool *  ok = nullptr,
int  base = 0 
) const

Returns the int represented by the localized string s using the given base. If the value for base is 0 it will be determined 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. Leading and trailing whitespace is ignored.

If the conversion fails 0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toUInt(), toString()
qint64 QLocale::toLongLong ( const QString s,
bool *  ok = nullptr,
int  base = 0 
) const

Returns the long long int represented by the localized string s using the given base. If the value for base is 0 it will be determined 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. Leading and trailing whitespace is ignored.

If the conversion fails 0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toInt(), toULongLong(), toDouble(), toString()
QString QLocale::toLower ( const QString str) const

Returns a lowercase copy of str.

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

Returns the short int represented by the localized string s using base. If the value for base is 0 it will be determined 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. Leading and trailing whitespace is ignored.

If the conversion fails 0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toUShort(), toString()
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 then an empty string is returned.

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

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

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

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

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

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

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 then an empty string is returned.

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

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

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

This method has the same meaning as calling QString::number(double, char, int).

See also
toDouble()
QString QLocale::toString ( float  value,
char  f = 'g',
int  prec = 6 
) const
inline

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

See also
toDouble()
QString QLocale::toString ( int  value) const
inline

This is an overloaded method.

See also
toInt()
QString QLocale::toString ( qint64  value) const

Returns a localized string representation of value.

See also
toLongLong()
QString QLocale::toString ( quint64  value) const

This is an overloaded method.

See also
toULongLong()
QString QLocale::toString ( short  value) const
inline

This is an overloaded method.

See also
toShort()
QString QLocale::toString ( uint  value) const
inline

This is an overloaded method.

See also
toUInt()
QString QLocale::toString ( ushort  value) const
inline

This is an overloaded method.

See also
toUShort()
QTime QLocale::toTime ( const QString string,
const QString format 
) const

Parses the time string given in string and returns the time. Refer to QTime::fromString() for information on what is a valid format string. If the time could not be parsed the method returns an invalid time.

See also
timeFormat(), toDate(), toDateTime(), QTime::fromString()
QTime QLocale::toTime ( const QString string,
FormatType  formatType = LongFormat 
) const

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

If the time could not be parsed this methods returns an invalid time.

See also
timeFormat(), toDate(), toDateTime(), QTime::fromString()
uint QLocale::toUInt ( const QString s,
bool *  ok = nullptr,
int  base = 0 
) const

Returns the unsigned int represented by the localized string s using base. If base is 0 it will be determined by 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. Leading and trailing whitespace is ignored.

If the conversion fails 0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toInt(), toString()
quint64 QLocale::toULongLong ( const QString s,
bool *  ok = nullptr,
int  base = 0 
) const

Returns the quint64 integer represented by the localized string s using base. If base is 0 it will be determined by 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. Leading and trailing whitespace are ignored.

If the conversion fails 0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toLongLong(), toInt(), toDouble(), toString()
QString QLocale::toUpper ( const QString str) const

Returns an uppercase copy of str.

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

Returns the unsigned short int represented by the localized string s using base. If base is 0 it will be determined by 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. Leading and trailing whitespace are ignored.

If the conversion fails 0 is returned. If ok is not a nullptr, this method will set the value according to the success of the conversion. The value is false to indicate the conversion failed, otherwise ok is set to true.

See also
toShort(), toString()
QStringList QLocale::uiLanguages ( ) const

Returns an list of locale names which can be used for translation purposes. This list indicates the possible locale names a user may want the UI translated to. The first item in the list is the most preferred one.

Normally this method is not used directly. Simply pass the QLocale object to the QTranslator::load() function.

See also
QTranslator, bcp47Name()
QList< Qt::DayOfWeek > QLocale::weekdays ( ) const

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

QChar QLocale::zeroDigit ( ) const

Returns the zero digit character of this locale.