CopperSpice API  1.7.2

Converts between numbers and their string representations in various languages. 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 converts between numbers and their string representations in various languages. 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.

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 specified in 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 by specifying 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>. Refer to QLocale::NumberOption for 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::Yemen 254
QLocale::Zambia 255
QLocale::Zimbabwe 256
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. Note that the narrow format might contain the same text for different months and days or it can even be an empty string if the locale 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::Bambara 30  
QLocale::Bamun 31  
QLocale::Bangla 32  
QLocale::Basaa 33  
QLocale::Bashkir 34  
QLocale::Basque 35  
QLocale::BatakToba 36  
QLocale::Belarusian 37  
QLocale::Bemba 38  
QLocale::Bena 39  
QLocale::Bengali Use Bangla  
QLocale::Bhojpuri 40  
QLocale::Bhutani Use Dzongkha  
QLocale::Bislama 41  
QLocale::Blin 42  
QLocale::Bodo 43  
QLocale::Bosnian 44  
QLocale::Breton 45  
QLocale::Buginese 46  
QLocale::Buhid 47  
QLocale::Bulgarian 48  
QLocale::Burmese 49  
QLocale::Byelorussian Use Belarusian  
QLocale::Cambodian Use Khmer  
QLocale::Cantonese 50  
QLocale::Carian 51  
QLocale::Catalan 52  
QLocale::Cebuano 53  
QLocale::CentralAtlasTamazight 54  
QLocale::CentralKurdish 55  
QLocale::Chakma 56  
QLocale::Chamorro 57  
QLocale::Chechen 58  
QLocale::Cherokee 59  
QLocale::Chewa Use Nyanja  
QLocale::Chickasaw 60  
QLocale::Chiga 61  
QLocale::Chinese 62  
QLocale::Church 63  
QLocale::Chuvash 64  
QLocale::ClassicalMandaic 65  
QLocale::Colognian 66  
QLocale::Coptic 67  
QLocale::Cornish 68  
QLocale::Corsican 69  
QLocale::Cree 70  
QLocale::Croatian 71  
QLocale::Czech 72  
QLocale::Danish 73  
QLocale::Divehi 74  
QLocale::Dogri 75  
QLocale::Duala 76  
QLocale::Dutch 77  
QLocale::Dzongkha 78  
QLocale::EasternCham 79  
QLocale::EasternKayah 80  
QLocale::Embu 81  
QLocale::English 82  
QLocale::Erzya 83  
QLocale::Esperanto 84  
QLocale::Estonian 85  
QLocale::Etruscan 86  
QLocale::Ewe 87  
QLocale::Ewondo 88  
QLocale::Faroese 89  
QLocale::Fijian 90  
QLocale::Filipino 91  
QLocale::Finnish 92  
QLocale::French 93  
QLocale::Frisian Use WesternFrisian  
QLocale::Friulian 94  
QLocale::Fulah 95  
QLocale::Ga 96  
QLocale::Gaelic 97  
QLocale::Galician 98  
QLocale::Ganda 99  
QLocale::Geez 100  
QLocale::Georgian 101  
QLocale::German 102  
QLocale::Gothic 103  
QLocale::Greek 104  
QLocale::Greenlandic Use Kalaallisut  
QLocale::Guarani 105  
QLocale::Gujarati 106  
QLocale::Gusii 107  
QLocale::Haitian 108  
QLocale::Hanunoo 109  
QLocale::Hausa 110  
QLocale::Hawaiian 111  
QLocale::Hebrew 112  
QLocale::Herero 113  
QLocale::Hindi 114  
QLocale::HiriMotu 115  
QLocale::HmongNjua 116  
QLocale::Ho 117  
QLocale::Hungarian 118  
QLocale::Icelandic 119  
QLocale::Igbo 120  
QLocale::InariSami 121  
QLocale::Indonesian 122  
QLocale::Ingush 123  
QLocale::Interlingua 124  
QLocale::Interlingue 125  
QLocale::Inuktitut 126  
QLocale::Inupiak Use Inupiaq  
QLocale::Inupiaq 127  
QLocale::Irish 128  
QLocale::Italian 129  
QLocale::Japanese 130  
QLocale::Javanese 131  
QLocale::Jju 132  
QLocale::JolaFonyi 133  
QLocale::Kabuverdianu 134  
QLocale::Kabyle 135  
QLocale::Kako 136  
QLocale::Kalaallisut 137  
QLocale::Kalenjin 138  
QLocale::Kamba 139  
QLocale::Kannada 140  
QLocale::Kanuri 141  
QLocale::Kashmiri 142  
QLocale::Kazakh 143  
QLocale::Kenyang 144  
QLocale::Khmer 145  
QLocale::Kiche 146  
QLocale::Kikuyu 147  
QLocale::Kinyarwanda 148  
QLocale::Komi 149  
QLocale::Kongo 150  
QLocale::Konkani 151  
QLocale::Korean 152  
QLocale::Koro 153  
QLocale::KoyraChiini 154  
QLocale::KoyraboroSenni 155  
QLocale::Kpelle 156  
QLocale::Kuanyama 157  
QLocale::Kurdish 158  
QLocale::Kurundi Use Rundi  
QLocale::Kwasio 159  
QLocale::Kyrgyz 160  
QLocale::Lakota 161  
QLocale::Langi 162  
QLocale::Lao 163  
QLocale::LargeFloweryMiao 164  
QLocale::Latin 165  
QLocale::Latvian 166  
QLocale::Lepcha 167  
QLocale::Lezghian 168  
QLocale::Limbu 169  
QLocale::Limburgish 170  
QLocale::LinearA 171  
QLocale::Lingala 172  
QLocale::Lisu 173  
QLocale::LiteraryChinese 174  
QLocale::Lithuanian 175  
QLocale::LowGerman 176  
QLocale::LowerSorbian 177  
QLocale::Lu 178  
QLocale::LubaKatanga 179  
QLocale::LuleSami 180  
QLocale::Luo 181  
QLocale::Luxembourgish 182  
QLocale::Luyia 183  
QLocale::Lycian 184  
QLocale::Lydian 185  
QLocale::Macedonian 186  
QLocale::Machame 187  
QLocale::Maithili 188  
QLocale::MakhuwaMeetto 189  
QLocale::Makonde 190  
QLocale::Malagasy 191  
QLocale::Malay 192  
QLocale::Malayalam 193  
QLocale::Maltese 194  
QLocale::Mandingo 195  
QLocale::ManichaeanMiddlePersian 196  
QLocale::Manipuri 197  
QLocale::Manx 198  
QLocale::Maori 199  
QLocale::Mapuche 200  
QLocale::Marathi 201  
QLocale::Marshallese 202  
QLocale::Masai 203  
QLocale::Mazanderani 204  
QLocale::Mende 205  
QLocale::Meroitic 206  
QLocale::Meru 207  
QLocale::Meta 208  
QLocale::Mohawk 209  
QLocale::Mongolian 210  
QLocale::Morisyen 211  
QLocale::Mundang 212  
QLocale::Muscogee 213  
QLocale::Nama 214  
QLocale::Nauru 215  
QLocale::Navaho Use Navajo  
QLocale::Navajo 216  
QLocale::Ndonga 217  
QLocale::Nepali 218  
QLocale::Newari 219  
QLocale::Ngiemboon 220  
QLocale::Ngomba 221  
QLocale::NigerianPidgin 222  
QLocale::Nko 223  
QLocale::NorthNdebele 224  
QLocale::NorthernLuri 225  
QLocale::NorthernSami 226  
QLocale::NorthernSotho 227  
QLocale::NorthernThai 228  
QLocale::NorwegianBokmal 229  
QLocale::NorwegianNynorsk 230  
QLocale::Nuer 231  
QLocale::Nyanja 232  
QLocale::Nyankole 233  
QLocale::Occitan 234  
QLocale::Odia 235  
QLocale::Ojibwa 236  
QLocale::OldIrish 237  
QLocale::OldNorse 238  
QLocale::OldPersian 239  
QLocale::OldTurkish 240  
QLocale::Oromo 241  
QLocale::Osage 242  
QLocale::Ossetic 243  
QLocale::Pahlavi 244  
QLocale::Palauan 245  
QLocale::Pali 246  
QLocale::Papiamento 247  
QLocale::Parthian 248  
QLocale::Pashto 249  
QLocale::Persian 250  
QLocale::Phoenician 251  
QLocale::Polish 252  
QLocale::Portuguese 253  
QLocale::Prussian 254  
QLocale::Punjabi 255  
QLocale::Quechua 256  
QLocale::Rejang 257  
QLocale::RhaetoRomance Use Romansh  
QLocale::Romanian 258  
QLocale::Romansh 259  
QLocale::Rombo 260  
QLocale::Rundi 261  
QLocale::Russian 262  
QLocale::Rwa 263  
QLocale::Sabaean 264  
QLocale::Saho 265  
QLocale::Sakha 266  
QLocale::Samaritan 267  
QLocale::Samburu 268  
QLocale::Samoan 269  
QLocale::Sango 270  
QLocale::Sangu 271  
QLocale::Sanskrit 272  
QLocale::Santali 273  
QLocale::Sardinian 274  
QLocale::Saurashtra 275  
QLocale::Sena 276  
QLocale::Serbian 277  
QLocale::Shambala 278  
QLocale::Shona 279  
QLocale::SichuanYi 280  
QLocale::Sicilian 281  
QLocale::Sidamo 282  
QLocale::Silesian 283  
QLocale::Sindhi 284  
QLocale::Sinhala 285  
QLocale::SkoltSami 286  
QLocale::Slovak 287  
QLocale::Slovenian 288  
QLocale::Soga 289  
QLocale::Somali 290  
QLocale::Sora 291  
QLocale::SouthNdebele 292  
QLocale::SouthernKurdish 293  
QLocale::SouthernSami 294  
QLocale::SouthernSotho 295  
QLocale::Spanish 296  
QLocale::StandardMoroccanTamazight 297  
QLocale::Sundanese 298  
QLocale::Swahili 299  
QLocale::Swati 300  
QLocale::Swedish 301  
QLocale::SwissGerman 302  
QLocale::Sylheti 303  
QLocale::Syriac 304  
QLocale::Tachelhit 305  
QLocale::Tagbanwa 306  
QLocale::Tahitian 307  
QLocale::TaiDam 308  
QLocale::TaiNua 309  
QLocale::Taita 310  
QLocale::Tajik 311  
QLocale::Tamil 312  
QLocale::Taroko 313  
QLocale::Tasawaq 314  
QLocale::Tatar 315  
QLocale::TedimChin 316  
QLocale::Telugu 317  
QLocale::Teso 318  
QLocale::Thai 319  
QLocale::Tibetan 320  
QLocale::Tigre 321  
QLocale::Tigrinya 322  
QLocale::TokPisin 323  
QLocale::Tokelau 324  
QLocale::Tongan 325  
QLocale::Tsonga 326  
QLocale::Tswana 327  
QLocale::Turkish 328  
QLocale::Turkmen 329  
QLocale::Tuvalu 330  
QLocale::Tyap 331  
QLocale::Ugaritic 332  
QLocale::Uighur Use Uyghur  
QLocale::Uigur Use Uyghur  
QLocale::Ukrainian 333  
QLocale::UpperSorbian 334  
QLocale::Urdu 335  
QLocale::Uyghur 336  
QLocale::Uzbek 337  
QLocale::Vai 338  
QLocale::Venda 339  
QLocale::Vietnamese 340  
QLocale::Volapuk 341  
QLocale::Vunjo 342  
QLocale::Walloon 343  
QLocale::Walser 344  
QLocale::Warlpiri 345  
QLocale::Welsh 346  
QLocale::WesternBalochi 347  
QLocale::WesternFrisian 348  
QLocale::Wolaytta 349  
QLocale::Wolof 350  
QLocale::Xhosa 351  
QLocale::Yangben 352  
QLocale::Yiddish 353  
QLocale::Yoruba 354  
QLocale::Zarma 355  
QLocale::Zhuang 356  
QLocale::Zulu 357  
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::ArabicScript 2
QLocale::ArmenianScript 3
QLocale::AvestanScript 4
QLocale::BalineseScript 5
QLocale::BamumScript 6
QLocale::BanglaScript 7
QLocale::BassaVahScript 8
QLocale::BatakScript 9
QLocale::BengaliScript Use BanglaScript
QLocale::BhaiksukiScript 10
QLocale::BopomofoScript 11
QLocale::BrahmiScript 12
QLocale::BrailleScript 13
QLocale::BugineseScript 14
QLocale::BuhidScript 15
QLocale::CanadianAboriginalScript 16
QLocale::CarianScript 17
QLocale::CaucasianAlbanianScript 18
QLocale::ChakmaScript 19
QLocale::ChamScript 20
QLocale::CherokeeScript 21
QLocale::CopticScript 22
QLocale::CuneiformScript 23
QLocale::CypriotScript 24
QLocale::CyrillicScript 25
QLocale::DeseretScript 26
QLocale::DevanagariScript 27
QLocale::DuployanScript 28
QLocale::EgyptianHieroglyphsScript 29
QLocale::ElbasanScript 30
QLocale::EthiopicScript 31
QLocale::FraserScript 32
QLocale::GeorgianScript 33
QLocale::GlagoliticScript 34
QLocale::GothicScript 35
QLocale::GranthaScript 36
QLocale::GreekScript 37
QLocale::GujaratiScript 38
QLocale::GurmukhiScript 39
QLocale::HanScript 40
QLocale::HangulScript 41
QLocale::HanunooScript 42
QLocale::HebrewScript 43
QLocale::HiraganaScript 44
QLocale::ImperialAramaicScript 45
QLocale::InscriptionalPahlaviScript 46
QLocale::InscriptionalParthianScript 47
QLocale::JapaneseScript 48
QLocale::JavaneseScript 49
QLocale::KaithiScript 50
QLocale::KannadaScript 51
QLocale::KatakanaScript 52
QLocale::KayahLiScript 53
QLocale::KharoshthiScript 54
QLocale::KhmerScript 55
QLocale::KhojkiScript 56
QLocale::KhudawadiScript 57
QLocale::KoreanScript 58
QLocale::LannaScript 59
QLocale::LaoScript 60
QLocale::LatinScript 61
QLocale::LepchaScript 62
QLocale::LimbuScript 63
QLocale::LinearAScript 64
QLocale::LinearBScript 65
QLocale::LycianScript 66
QLocale::LydianScript 67
QLocale::MahajaniScript 68
QLocale::MalayalamScript 69
QLocale::MandaeanScript 70
QLocale::ManichaeanScript 71
QLocale::MeiteiMayekScript 72
QLocale::MendeScript 73
QLocale::MendeKikakuiScript Use MendeScript
QLocale::MeroiticScript 75
QLocale::MeroiticCursiveScript 74
QLocale::ModiScript 76
QLocale::MongolianScript 77
QLocale::MroScript 78
QLocale::MyanmarScript 79
QLocale::NabataeanScript 80
QLocale::NewTaiLueScript 81
QLocale::NkoScript 82
QLocale::OdiaScript 83
QLocale::OghamScript 84
QLocale::OlChikiScript 85
QLocale::OldItalicScript 86
QLocale::OldNorthArabianScript 87
QLocale::OldPermicScript 88
QLocale::OldPersianScript 89
QLocale::OldSouthArabianScript 90
QLocale::OriyaScript Use OdiaScript
QLocale::OrkhonScript 91
QLocale::OsageScript 92
QLocale::OsmanyaScript 93
QLocale::PahawhHmongScript 94
QLocale::PalmyreneScript 95
QLocale::PauCinHauScript 96
QLocale::PhagsPaScript 97
QLocale::PhoenicianScript 98
QLocale::PollardPhoneticScript 99
QLocale::PsalterPahlaviScript 100
QLocale::RejangScript 101
QLocale::RunicScript 102
QLocale::SamaritanScript 103
QLocale::SaurashtraScript 104
QLocale::SharadaScript 105
QLocale::ShavianScript 106
QLocale::SiddhamScript 107
QLocale::SimplifiedHanScript 108
QLocale::SimplifiedChineseScript Use SimplifiedHanScript
QLocale::SinhalaScript 109
QLocale::SoraSompengScript 110
QLocale::SundaneseScript 111
QLocale::SylotiNagriScript 112
QLocale::SyriacScript 113
QLocale::TagalogScript 114
QLocale::TagbanwaScript 115
QLocale::TaiLeScript 116
QLocale::TaiVietScript 117
QLocale::TakriScript 118
QLocale::TamilScript 119
QLocale::TeluguScript 120
QLocale::ThaanaScript 121
QLocale::ThaiScript 122
QLocale::TibetanScript 123
QLocale::TifinaghScript 124
QLocale::TirhutaScript 125
QLocale::TraditionalHanScript 126
QLocale::TraditionalChineseScript Use TraditionalHanScript
QLocale::UgariticScript 127
QLocale::VaiScript 128
QLocale::VarangKshitiScript 129
QLocale::YiScript 130
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 or 0.0 if the conversion failed. Unlike QString::toDouble() this method does not fall back to the "C" locale if the string can not be interpreted in this locale.

If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace is ignored.

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 if the conversion failed. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace is ignored.

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 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 0 is returned. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace is ignored.

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 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 0 is returned. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace is ignored.

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 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 0 is returned. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace is ignored.

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 i.

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. See 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 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 0 is returned. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace is ignored.

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 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 0 is returned. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace are ignored.

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 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 0 is returned. If ok is not a nullptr then this method will set the value according to the success of the conversion. Leading and trailing whitespace are ignored.

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.