IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QLocale Class

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QLocale Class

  • Header: QLocale

  • qmake: QT += core

  • Inherited By:

  • Group: QLocale is part of i18n, string-processing, Implicitly Shared Classes

Detailed Description

QLocale is initialized with a language/country pair in its constructor and offers number-to-string and string-to-number conversion functions similar to those in QString.

Example:

 
Sélectionnez
QLocale egyptian(QLocale::Arabic, QLocale::Egypt);
QString s1 = egyptian.toString(1.571429E+07, 'e');
QString s2 = egyptian.toString(10);

double d = egyptian.toDouble(s1);
int i = egyptian.toInt(s2);

QLocale supports the concept of a default locale, which is determined from the system's locale settings at application startup. The default locale can be changed by calling the static member setDefault(). Setting the default locale has the following effects:

  • If a QLocale object is constructed with the default constructor, it will use the default locale's settings.

  • QString::toInt(), QString::toDouble(), etc., interpret the string according to the default locale. If this fails, it falls back on the "C" locale.

  • QString::arg() uses the default locale to format a number when its position specifier in the format string contains an 'L', e.g. "%L1".

The following example illustrates how to use QLocale directly:

 
Sélectionnez
QLocale::setDefault(QLocale(QLocale::Hebrew, QLocale::Israel));
QLocale hebrew; // Constructs a default QLocale
QString s1 = hebrew.toString(15714.3, 'e');

bool ok;
double d;

QLocale::setDefault(QLocale::C);
d = QString("1234,56").toDouble(&ok);   // ok == false
d = QString("1234.56").toDouble(&ok);   // ok == true, d == 1234.56

QLocale::setDefault(QLocale::German);
d = QString("1234,56").toDouble(&ok);   // ok == true, d == 1234.56
d = QString("1234.56").toDouble(&ok);   // ok == true, d == 1234.56

QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
str = QString("%1 %L2 %L3")
      .arg(12345).arg(12345).arg(12345, 0, 16);
// str == "12345 12,345 3039"

When a language/country pair is specified in the constructor, one of three things can happen:

  • If the language/country pair is found in the database, it is used.

  • If the language is found but the country is not, or if the country is AnyCountry, the language is used with the most appropriate available country (for example, Germany for German),

  • If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).

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

An alternative method for constructing a QLocale object is by specifying the locale name.

 
Sélectionnez
QLocale korean("ko");
QLocale swiss("de_CH");

This constructor converts the locale name to a language/country pair; it does not use the system locale database.

For the current keyboard input locale take a look at QInputMethod::locale().

QLocale's data is based on Common Locale Data Repository v35.1.

See Also

Member Type Documentation

 

enum QLocale::Country

This enumerated type is used to specify a country.

Constant

Value

QLocale::AnyCountry

0

 

QLocale::Afghanistan

1

 

QLocale::Albania

2

 

QLocale::Algeria

3

 

QLocale::AmericanSamoa

4

 

QLocale::Andorra

5

 

QLocale::Angola

6

 

QLocale::Anguilla

7

 

QLocale::Antarctica

8

 

QLocale::AntiguaAndBarbuda

9

 

QLocale::Argentina

10

 

QLocale::Armenia

11

 

QLocale::Aruba

12

 

QLocale::Australia

13

 

QLocale::Austria

14

 

QLocale::Azerbaijan

15

 

QLocale::Bahamas

16

 

QLocale::Bahrain

17

 

QLocale::Bangladesh

18

 

QLocale::Barbados

19

 

QLocale::Belarus

20

 

QLocale::Belgium

21

 

QLocale::Belize

22

 

QLocale::Benin

23

 

QLocale::Bermuda

24

 

QLocale::Bhutan

25

 

QLocale::Bolivia

26

 

QLocale::BosniaAndHerzegowina

27

 

QLocale::Botswana

28

 

QLocale::BouvetIsland

29

 

QLocale::Brazil

30

 

QLocale::BritishIndianOceanTerritory

31

 

QLocale::Brunei

32

 

QLocale::Bulgaria

33

 

QLocale::BurkinaFaso

34

 

QLocale::Burundi

35

 

QLocale::Cambodia

36

 

QLocale::Cameroon

37

 

QLocale::Canada

38

 

QLocale::CanaryIslands

238

 

QLocale::CapeVerde

39

 

QLocale::CaymanIslands

40

 

QLocale::CentralAfricanRepublic

41

 

QLocale::Chad

42

 

QLocale::Chile

43

 

QLocale::China

44

 

QLocale::ChristmasIsland

45

 

QLocale::ClippertonIsland

241

 

QLocale::CocosIslands

46

 

QLocale::Colombia

47

 

QLocale::Comoros

48

 

QLocale::CongoKinshasa

49

 

QLocale::CongoBrazzaville

50

 

QLocale::DemocraticRepublicOfCongo

CongoKinshasa

Obsolete, please use CongoKinshasa

QLocale::PeoplesRepublicOfCongo

CongoBrazzaville

Obsolete, please use CongoBrazzaville

QLocale::CookIslands

51

 

QLocale::CostaRica

52

 

QLocale::IvoryCoast

53

 

QLocale::Croatia

54

 

QLocale::Cuba

55

 

QLocale::Cyprus

56

 

QLocale::CzechRepublic

57

 

QLocale::Denmark

58

 

QLocale::Djibouti

59

 

QLocale::Dominica

60

 

QLocale::DominicanRepublic

61

 

QLocale::EastTimor

62

 

QLocale::Ecuador

63

 

QLocale::Egypt

64

 

QLocale::ElSalvador

65

 

QLocale::EquatorialGuinea

66

 

QLocale::Eritrea

67

 

QLocale::Estonia

68

 

QLocale::Ethiopia

69

 

QLocale::EuropeanUnion

258

Since Qt 5.7

QLocale::Europe

261

Since Qt 5.12

QLocale::FalklandIslands

70

 

QLocale::FaroeIslands

71

 

QLocale::Fiji

72

 

QLocale::Finland

73

 

QLocale::France

74

 

QLocale::FrenchGuiana

76

 

QLocale::FrenchPolynesia

77

 

QLocale::FrenchSouthernTerritories

78

 

QLocale::Gabon

79

 

QLocale::Gambia

80

 

QLocale::Georgia

81

 

QLocale::Germany

82

 

QLocale::Ghana

83

 

QLocale::Gibraltar

84

 

QLocale::Greece

85

 

QLocale::Greenland

86

 

QLocale::Grenada

87

 

QLocale::Guadeloupe

88

 

QLocale::Guam

89

 

QLocale::Guatemala

90

 

QLocale::Guernsey

75

 

QLocale::Guinea

91

 

QLocale::GuineaBissau

92

 

QLocale::Guyana

93

 

QLocale::Haiti

94

 

QLocale::HeardAndMcDonaldIslands

95

 

QLocale::Honduras

96

 

QLocale::HongKong

97

 

QLocale::Hungary

98

 

QLocale::Iceland

99

 

QLocale::India

100

 

QLocale::Indonesia

101

 

QLocale::Iran

102

 

QLocale::Iraq

103

 

QLocale::Ireland

104

 

QLocale::Israel

105

 

QLocale::Italy

106

 

QLocale::Jamaica

107

 

QLocale::Japan

108

 

QLocale::Jordan

109

 

QLocale::Kazakhstan

110

 

QLocale::Kenya

111

 

QLocale::Kiribati

112

 

QLocale::NorthKorea

113

 

QLocale::SouthKorea

114

 

QLocale::DemocraticRepublicOfKorea

NorthKorea

Obsolete, please use NorthKorea

QLocale::RepublicOfKorea

SouthKorea

Obsolete, please use SouthKorea

QLocale::Kosovo

257

 

QLocale::Kuwait

115

 

QLocale::Kyrgyzstan

116

 

QLocale::Laos

117

 

QLocale::LatinAmerica

246

 

QLocale::LatinAmericaAndTheCaribbean

LatinAmerica

Obsolete, please use LatinAmerica

QLocale::Latvia

118

 

QLocale::Lebanon

119

 

QLocale::Lesotho

120

 

QLocale::Liberia

121

 

QLocale::Libya

122

 

QLocale::Liechtenstein

123

 

QLocale::Lithuania

124

 

QLocale::Luxembourg

125

 

QLocale::Macau

126

 

QLocale::Macedonia

127

 

QLocale::Madagascar

128

 

QLocale::Malawi

129

 

QLocale::Malaysia

130

 

QLocale::Maldives

131

 

QLocale::Mali

132

 

QLocale::Malta

133

 

QLocale::MarshallIslands

134

 

QLocale::Martinique

135

 

QLocale::Mauritania

136

 

QLocale::Mauritius

137

 

QLocale::Mayotte

138

 

QLocale::Mexico

139

 

QLocale::Micronesia

140

 

QLocale::Moldova

141

 

QLocale::Monaco

142

 

QLocale::Mongolia

143

 

QLocale::Montserrat

144

 

QLocale::Morocco

145

 

QLocale::Mozambique

146

 

QLocale::Myanmar

147

 

QLocale::Namibia

148

 

QLocale::NauruCountry

149

 

QLocale::Nepal

150

 

QLocale::Netherlands

151

 

QLocale::NewCaledonia

153

 

QLocale::NewZealand

154

 

QLocale::Nicaragua

155

 

QLocale::Niger

156

 

QLocale::Nigeria

157

 

QLocale::Niue

158

 

QLocale::NorfolkIsland

159

 

QLocale::NorthernMarianaIslands

160

 

QLocale::Norway

161

 

QLocale::Oman

162

 

QLocale::OutlyingOceania

259

Since Qt 5.7

QLocale::Pakistan

163

 

QLocale::Palau

164

 

QLocale::PalestinianTerritories

165

 

QLocale::Panama

166

 

QLocale::PapuaNewGuinea

167

 

QLocale::Paraguay

168

 

QLocale::Peru

169

 

QLocale::Philippines

170

 

QLocale::Pitcairn

171

 

QLocale::Poland

172

 

QLocale::Portugal

173

 

QLocale::PuertoRico

174

 

QLocale::Qatar

175

 

QLocale::Reunion

176

 

QLocale::Romania

177

 

QLocale::Russia

178

same as RussianFederation

QLocale::RussianFederation

Russia

same as Russia

QLocale::Rwanda

179

 

QLocale::SaintKittsAndNevis

180

 

QLocale::SaintLucia

181

 

QLocale::SaintVincentAndTheGrenadines

182

 

QLocale::Samoa

183

 

QLocale::SanMarino

184

 

QLocale::SaoTomeAndPrincipe

185

 

QLocale::SaudiArabia

186

 

QLocale::Senegal

187

 

QLocale::Seychelles

188

 

QLocale::SierraLeone

189

 

QLocale::Singapore

190

 

QLocale::Slovakia

191

 

QLocale::Slovenia

192

 

QLocale::SolomonIslands

193

 

QLocale::Somalia

194

 

QLocale::SouthAfrica

195

 

QLocale::SouthGeorgiaAndTheSouthSandwichIslands

196

 

QLocale::Spain

197

 

QLocale::SriLanka

198

 

QLocale::SaintHelena

199

 

QLocale::SaintPierreAndMiquelon

200

 

QLocale::Sudan

201

 

QLocale::Suriname

202

 

QLocale::SvalbardAndJanMayenIslands

203

 

QLocale::Swaziland

204

 

QLocale::Sweden

205

 

QLocale::Switzerland

206

 

QLocale::Syria

207

 

QLocale::SyrianArabRepublic

Syria

Obsolete, please use Syria

QLocale::Taiwan

208

 

QLocale::Tajikistan

209

 

QLocale::Tanzania

210

 

QLocale::Thailand

211

 

QLocale::Togo

212

 

QLocale::TokelauCountry

213

 

QLocale::Tokelau

TokelauCountry

Obsolete, please use TokelauCountry

QLocale::Tonga

214

 

QLocale::TrinidadAndTobago

215

 

QLocale::Tunisia

216

 

QLocale::Turkey

217

 

QLocale::Turkmenistan

218

 

QLocale::TurksAndCaicosIslands

219

 

QLocale::TuvaluCountry

220

 

QLocale::Tuvalu

TuvaluCountry

Obsolete, please use TuvaluCountry

QLocale::Uganda

221

 

QLocale::Ukraine

222

 

QLocale::UnitedArabEmirates

223

 

QLocale::UnitedKingdom

224

 

QLocale::UnitedStates

225

 

QLocale::UnitedStatesMinorOutlyingIslands

226

 

QLocale::Uruguay

227

 

QLocale::Uzbekistan

228

 

QLocale::Vanuatu

229

 

QLocale::VaticanCityState

230

 

QLocale::Venezuela

231

 

QLocale::Vietnam

232

 

QLocale::BritishVirginIslands

233

 

QLocale::UnitedStatesVirginIslands

234

 

QLocale::WallisAndFutunaIslands

235

 

QLocale::WesternSahara

236

 

QLocale::World

260

Since Qt 5.12

QLocale::Yemen

237

 

QLocale::Zambia

239

 

QLocale::Zimbabwe

240

 

QLocale::Montenegro

242

 

QLocale::Serbia

243

 

QLocale::SaintBarthelemy

244

 

QLocale::SaintMartin

245

 

QLocale::AscensionIsland

247

 

QLocale::AlandIslands

248

 

QLocale::DiegoGarcia

249

 

QLocale::CeutaAndMelilla

250

 

QLocale::IsleOfMan

251

 

QLocale::Jersey

252

 

QLocale::TristanDaCunha

253

 

QLocale::SouthSudan

254

 

QLocale::CuraSao

152

 

QLocale::Bonaire

255

 

QLocale::SintMaarten

256

 
See Also

See also country(), countryToString()

[since 4.8] enum QLocale::CurrencySymbolFormat

Specifies the format of the currency symbol.

Constant

Value

Description

QLocale::CurrencyIsoCode

0

a ISO-4217 code of the currency.

QLocale::CurrencySymbol

1

a currency symbol.

QLocale::CurrencyDisplayName

2

a user readable name of the currency.

This enum was introduced or modified in Qt 4.8.

[since 5.10] enum QLocale::DataSizeFormat

flags QLocale::DataSizeFormats

Specifies the format for representation of data quantities.

Constant

Value

Description

QLocale::DataSizeIecFormat

0

format using base 1024 and IEC prefixes: KiB, MiB, GiB, ...

QLocale::DataSizeTraditionalFormat

DataSizeSIQuantifiers

format using base 1024 and SI prefixes: kB, MB, GB, ...

QLocale::DataSizeSIFormat

DataSizeBase1000 | DataSizeSIQuantifiers

format using base 1000 and SI prefixes: kB, MB, GB, ...

This enum was introduced or modified in Qt 5.10.

The DataSizeFormats type is a typedef for QFlags<DataSizeFormat>. It stores an OR combination of DataSizeFormat values.

See Also

See also formattedDataSize()

[since 5.7] enum QLocale::FloatingPointPrecisionOption

This enum defines constants that can be given as precision to QString::number(), QByteArray::number(), and QLocale::toString() when converting floats or doubles, in order to express a variable number of digits as precision.

Constant

Value

Description

QLocale::FloatingPointShortest

-128

The conversion algorithm will try to find the shortest accurate representation for the given number. "Accurate" means that you get the exact same number back from an inverse conversion on the generated string representation.

This enum was introduced or modified in Qt 5.7.

See Also

See also toString(), QString, QByteArray

enum QLocale::FormatType

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

Constant

Value

Description

QLocale::LongFormat

0

The long version of day and month names; for example, returning "January" as a month name.

QLocale::ShortFormat

1

The short version of day and month names; for example, returning "Jan" as a month name.

QLocale::NarrowFormat

2

A special version of day and month names for use when space is limited; for example, returning "J" as a month name. Note that the narrow format might contain the same text for different months and days or it can even be an empty string if the locale doesn't support narrow names, so you should avoid using it for date formatting. Also, for the system locale this format is the same as ShortFormat.

See Also

enum QLocale::Language

This enumerated type is used to specify a language.

Constant

Value

QLocale::AnyLanguage

0

 

QLocale::C

1

A simplified English locale; see QLocale::c()

QLocale::Abkhazian

2

 

QLocale::Oromo

3

 

QLocale::Afan

Oromo

Obsolete, please use Oromo

QLocale::Afar

4

 

QLocale::Afrikaans

5

 

QLocale::Akoose

312

Since Qt 5.3

QLocale::Albanian

6

 

QLocale::Amharic

7

 

QLocale::Arabic

8

 

QLocale::Armenian

9

 

QLocale::Assamese

10

 

QLocale::Avaric

216

 

QLocale::Aymara

11

 

QLocale::Azerbaijani

12

 

QLocale::Bashkir

13

 

QLocale::Basque

14

 

QLocale::Bengali

15

 

QLocale::Dzongkha

16

 

QLocale::Bhutani

Dzongkha

Obsolete, please use Dzongkha

QLocale::Bihari

17

 

QLocale::Bislama

18

 

QLocale::Bosnian

142

 

QLocale::Bodo

215

 

QLocale::Breton

19

 

QLocale::Bulgarian

20

 

QLocale::Burmese

21

 

QLocale::Belarusian

22

 

QLocale::Byelorussian

Belarusian

Obsolete, please use Belarusian

QLocale::Khmer

23

 

QLocale::Cambodian

Khmer

Obsolete, please use Khmer

QLocale::Catalan

24

 

QLocale::Chamorro

217

 

QLocale::Chechen

218

 

QLocale::Chinese

25

 

QLocale::Church

219

 

QLocale::Chuvash

220

 

QLocale::Cornish

145

 

QLocale::Corsican

26

 

QLocale::Cree

221

 

QLocale::Croatian

27

 

QLocale::Czech

28

 

QLocale::Danish

29

 

QLocale::Divehi

143

 

QLocale::Dutch

30

 

QLocale::English

31

 

QLocale::Esperanto

32

 

QLocale::Estonian

33

 

QLocale::Faroese

34

 

QLocale::Fijian

35

 

QLocale::Finnish

36

 

QLocale::French

37

 

QLocale::WesternFrisian

38

same as Frisian

QLocale::Frisian

WesternFrisian

same as WesternFrisian

QLocale::Gaelic

39

 

QLocale::Galician

40

 

QLocale::Georgian

41

 

QLocale::German

42

 

QLocale::Greek

43

 

QLocale::Greenlandic

44

 

QLocale::Guarani

45

 

QLocale::Gujarati

46

 

QLocale::Haitian

222

 

QLocale::Hausa

47

 

QLocale::Hebrew

48

 

QLocale::Herero

223

 

QLocale::Hindi

49

 

QLocale::HiriMotu

224

 

QLocale::Hungarian

50

 

QLocale::Icelandic

51

 

QLocale::Indonesian

52

 

QLocale::Interlingua

53

 

QLocale::Interlingue

54

 

QLocale::Inuktitut

55

 

QLocale::Inupiak

56

 

QLocale::Irish

57

 

QLocale::Italian

58

 

QLocale::Japanese

59

 

QLocale::Javanese

60

 

QLocale::Kannada

61

 

QLocale::Kanuri

225

 

QLocale::Kashmiri

62

 

QLocale::Kazakh

63

 

QLocale::Kinyarwanda

64

 

QLocale::Kirghiz

65

 

QLocale::Komi

226

 

QLocale::Kongo

227

 

QLocale::Korean

66

 

QLocale::Kurdish

67

 

QLocale::Rundi

68

 

QLocale::Kurundi

Rundi

Obsolete, please use Rundi

QLocale::Kwanyama

228

 

QLocale::Lakota

313

Since Qt 5.3

QLocale::Lao

69

 

QLocale::Latin

70

 

QLocale::Latvian

71

 

QLocale::Limburgish

229

 

QLocale::Lingala

72

 

QLocale::Lithuanian

73

 

QLocale::LubaKatanga

230

 

QLocale::Luxembourgish

231

 

QLocale::Marshallese

81

 

QLocale::Macedonian

74

 

QLocale::Malagasy

75

 

QLocale::Malay

76

 

QLocale::Malayalam

77

 

QLocale::Maltese

78

 

QLocale::Manx

144

 

QLocale::Maori

79

 

QLocale::Marathi

80

 

QLocale::Moldavian

Romanian

Obsolete, please use Romanian

QLocale::Mongolian

82

 

QLocale::NauruLanguage

83

 

QLocale::Navaho

232

 

QLocale::Ndonga

233

 

QLocale::Nepali

84

 

QLocale::Norwegian

NorwegianBokmal

same as NorwegianBokmal

QLocale::NorwegianBokmal

85

same as Norwegian

QLocale::NorwegianNynorsk

141

 

QLocale::Occitan

86

 

QLocale::Ojibwa

234

 

QLocale::Oriya

87

 

QLocale::Ossetic

101

 

QLocale::Pali

235

 

QLocale::Pashto

88

 

QLocale::Persian

89

 

QLocale::Polish

90

 

QLocale::Portuguese

91

 

QLocale::Punjabi

92

 

QLocale::Quechua

93

 

QLocale::Romansh

94

 

QLocale::RhaetoRomance

Romansh

Obsolete, please use Romansh

QLocale::Romanian

95

 

QLocale::Russian

96

 

QLocale::Samoan

97

 

QLocale::Sango

98

 

QLocale::Sanskrit

99

 

QLocale::Sardinian

115

 

QLocale::Serbian

100

 

QLocale::SerboCroatian

Serbian

Obsolete, please use Serbian

QLocale::SouthernSotho

102

 

QLocale::Tswana

103

 

QLocale::Shona

104

 

QLocale::Sindhi

105

 

QLocale::Sinhala

106

 

QLocale::Swati

107

 

QLocale::Slovak

108

 

QLocale::Slovenian

109

 

QLocale::Somali

110

 

QLocale::Spanish

111

 

QLocale::StandardMoroccanTamazight

314

Since Qt 5.3

QLocale::Sundanese

112

 

QLocale::Swahili

113

 

QLocale::Swedish

114

 

QLocale::Tagalog

Filipino

Obsolete, please use Filipino

QLocale::Tahitian

127

 

QLocale::Tajik

116

 

QLocale::Tamil

117

 

QLocale::Tatar

118

 

QLocale::Telugu

119

 

QLocale::Thai

120

 

QLocale::Tibetan

121

 

QLocale::Tigrinya

122

 

QLocale::Tongan

123

 

QLocale::Tsonga

124

 

QLocale::Turkish

125

 

QLocale::Turkmen

126

 

QLocale::Twi

Akan

Obsolete, please use Akan

QLocale::Uighur

128

 

QLocale::Uigur

Uighur

Obsolete, please use Uighur

QLocale::Ukrainian

129

 

QLocale::Urdu

130

 

QLocale::Uzbek

131

 

QLocale::Vietnamese

132

 

QLocale::Volapuk

133

 

QLocale::Walloon

236

 

QLocale::Welsh

134

 

QLocale::Wolof

135

 

QLocale::Xhosa

136

 

QLocale::Yiddish

137

 

QLocale::Yoruba

138

 

QLocale::Zhuang

139

 

QLocale::Zulu

140

 

QLocale::Bosnian

142

 

QLocale::Divehi

143

 

QLocale::Manx

144

 

QLocale::Cornish

145

 

QLocale::Akan

146

 

QLocale::Konkani

147

 

QLocale::Ga

148

 

QLocale::Igbo

149

 

QLocale::Kamba

150

 

QLocale::Syriac

151

 

QLocale::Blin

152

 

QLocale::Geez

153

 

QLocale::Koro

154

 

QLocale::Sidamo

155

 

QLocale::Atsam

156

 

QLocale::Tigre

157

 

QLocale::Jju

158

 

QLocale::Friulian

159

 

QLocale::Venda

160

 

QLocale::Ewe

161

 

QLocale::Walamo

162

 

QLocale::Hawaiian

163

 

QLocale::Tyap

164

 

QLocale::Nyanja

165

 

QLocale::Chewa

Nyanja

Obsolete, please use Nyanja

QLocale::Filipino

166

 

QLocale::SwissGerman

167

 

QLocale::SichuanYi

168

 

QLocale::Kpelle

169

 

QLocale::LowGerman

170

 

QLocale::SouthNdebele

171

 

QLocale::NorthernSotho

172

 

QLocale::NorthernSami

173

 

QLocale::Taroko

174

 

QLocale::Gusii

175

 

QLocale::Taita

176

 

QLocale::Fulah

177

 

QLocale::Kikuyu

178

 

QLocale::Samburu

179

 

QLocale::Sena

180

 

QLocale::NorthNdebele

181

 

QLocale::Rombo

182

 

QLocale::Tachelhit

183

 

QLocale::Kabyle

184

 

QLocale::Nyankole

185

 

QLocale::Bena

186

 

QLocale::Vunjo

187

 

QLocale::Bambara

188

 

QLocale::Embu

189

 

QLocale::Cherokee

190

 

QLocale::Morisyen

191

 

QLocale::Makonde

192

 

QLocale::Langi

193

 

QLocale::Ganda

194

 

QLocale::Bemba

195

 

QLocale::Kabuverdianu

196

 

QLocale::Meru

197

 

QLocale::Kalenjin

198

 

QLocale::Nama

199

 

QLocale::Machame

200

 

QLocale::Colognian

201

 

QLocale::Masai

202

 

QLocale::Soga

203

 

QLocale::Luyia

204

 

QLocale::Asu

205

 

QLocale::Teso

206

 

QLocale::Saho

207

 

QLocale::KoyraChiini

208

 

QLocale::Rwa

209

 

QLocale::Luo

210

 

QLocale::Chiga

211

 

QLocale::CentralMoroccoTamazight

212

 

QLocale::KoyraboroSenni

213

 

QLocale::Shambala

214

 

QLocale::Aghem

237

 

QLocale::Basaa

238

 

QLocale::Zarma

239

 

QLocale::Duala

240

 

QLocale::JolaFonyi

241

 

QLocale::Ewondo

242

 

QLocale::Bafia

243

 

QLocale::MakhuwaMeetto

244

 

QLocale::Mundang

245

 

QLocale::Kwasio

246

 

QLocale::Nuer

247

 

QLocale::Sakha

248

 

QLocale::Sangu

249

 

QLocale::CongoSwahili

250

 

QLocale::Tasawaq

251

 

QLocale::Vai

252

 

QLocale::Walser

253

 

QLocale::Yangben

254

 

QLocale::Avestan

255

 

QLocale::Asturian

256

 

QLocale::Ngomba

257

 

QLocale::Kako

258

 

QLocale::Meta

259

 

QLocale::Ngiemboon

260

 

QLocale::Aragonese

261

 

QLocale::Akkadian

262

 

QLocale::AncientEgyptian

263

 

QLocale::AncientGreek

264

 

QLocale::Aramaic

265

 

QLocale::Balinese

266

 

QLocale::Bamun

267

 

QLocale::BatakToba

268

 

QLocale::Buginese

269

 

QLocale::Buhid

270

 

QLocale::Carian

271

 

QLocale::Chakma

272

 

QLocale::ClassicalMandaic

273

 

QLocale::Coptic

274

 

QLocale::Dogri

275

 

QLocale::EasternCham

276

 

QLocale::EasternKayah

277

 

QLocale::Etruscan

278

 

QLocale::Gothic

279

 

QLocale::Hanunoo

280

 

QLocale::Ingush

281

 

QLocale::LargeFloweryMiao

282

 

QLocale::Lepcha

283

 

QLocale::Limbu

284

 

QLocale::Lisu

285

 

QLocale::Lu

286

 

QLocale::Lycian

287

 

QLocale::Lydian

288

 

QLocale::Mandingo

289

 

QLocale::Manipuri

290

 

QLocale::Meroitic

291

 

QLocale::NorthernThai

292

 

QLocale::OldIrish

293

 

QLocale::OldNorse

294

 

QLocale::OldPersian

295

 

QLocale::OldTurkish

296

 

QLocale::Pahlavi

297

 

QLocale::Parthian

298

 

QLocale::Phoenician

299

 

QLocale::PrakritLanguage

300

 

QLocale::Rejang

301

 

QLocale::Sabaean

302

 

QLocale::Samaritan

303

 

QLocale::Santali

304

 

QLocale::Saurashtra

305

 

QLocale::Sora

306

 

QLocale::Sylheti

307

 

QLocale::Tagbanwa

308

 

QLocale::TaiDam

309

 

QLocale::TaiNua

310

 

QLocale::Ugaritic

311

 

QLocale::Mapuche

315

Since Qt 5.5

QLocale::CentralKurdish

316

Since Qt 5.5

QLocale::LowerSorbian

317

Since Qt 5.5

QLocale::UpperSorbian

318

Since Qt 5.5

QLocale::Kenyang

319

Since Qt 5.5

QLocale::Mohawk

320

Since Qt 5.5

QLocale::Nko

321

Since Qt 5.5

QLocale::Prussian

322

Since Qt 5.5

QLocale::Kiche

323

Since Qt 5.5

QLocale::SouthernSami

324

Since Qt 5.5

QLocale::LuleSami

325

Since Qt 5.5

QLocale::InariSami

326

Since Qt 5.5

QLocale::SkoltSami

327

Since Qt 5.5

QLocale::Warlpiri

328

Since Qt 5.5

QLocale::ManichaeanMiddlePersian

329

Since Qt 5.5

QLocale::Mende

330

Since Qt 5.5

QLocale::AncientNorthArabian

331

Since Qt 5.5

QLocale::LinearA

332

Since Qt 5.5

QLocale::HmongNjua

333

Since Qt 5.5

QLocale::Ho

334

Since Qt 5.5

QLocale::Lezghian

335

Since Qt 5.5

QLocale::Bassa

336

Since Qt 5.5

QLocale::Mono

337

Since Qt 5.5

QLocale::TedimChin

338

Since Qt 5.5

QLocale::Maithili

339

Since Qt 5.5

QLocale::LowerSorbian

317

Since Qt 5.5

QLocale::UpperSorbian

318

Since Qt 5.5

QLocale::Ahom

340

Since Qt 5.7

QLocale::AmericanSignLanguage

341

Since Qt 5.7

QLocale::ArdhamagadhiPrakrit

342

Since Qt 5.7

QLocale::Bhojpuri

343

Since Qt 5.7

QLocale::Cantonese

357

Since Qt 5.7

QLocale::HieroglyphicLuwian

344

Since Qt 5.7

QLocale::LiteraryChinese

345

Since Qt 5.7

QLocale::Mazanderani

346

Since Qt 5.7

QLocale::Mru

347

Since Qt 5.7

QLocale::Newari

348

Since Qt 5.7

QLocale::NorthernLuri

349

Since Qt 5.7

QLocale::Osage

358

Since Qt 5.7

QLocale::Palauan

350

Since Qt 5.7

QLocale::Papiamento

351

Since Qt 5.7

QLocale::Saraiki

352

Since Qt 5.7

QLocale::Tangut

359

Since Qt 5.7

QLocale::TokelauLanguage

353

Since Qt 5.7

QLocale::TokPisin

354

Since Qt 5.7

QLocale::TuvaluLanguage

355

Since Qt 5.7

QLocale::UncodedLanguages

356

Since Qt 5.7

See Also

See also language(), languageToString()

[since 4.4] enum QLocale::MeasurementSystem

This enum defines which units are used for measurement.

Constant

Value

Description

QLocale::MetricSystem

0

This value indicates metric units, such as meters, centimeters and millimeters.

QLocale::ImperialUSSystem

1

This value indicates imperial units, such as inches and miles as they are used in the United States.

QLocale::ImperialUKSystem

2

This value indicates imperial units, such as inches and miles as they are used in the United Kingdom.

QLocale::ImperialSystem

ImperialUSSystem

Provided for compatibility. Same as ImperialUSSystem

This enum was introduced or modified in Qt 4.4.

enum QLocale::NumberOption

flags QLocale::NumberOptions

This enum defines a set of options for number-to-string and string-to-number conversions. They can be retrieved with numberOptions() and set with setNumberOptions().

Constant

Value

Description

QLocale::DefaultNumberOptions

0x0

This option represents the default behavior, with group separators, with one leading zero in single digit exponents, and without trailing zeroes after the decimal dot.

QLocale::OmitGroupSeparator

0x01

If this option is set, the number-to-string functions will not insert group separators in their return values. The default is to insert group separators.

QLocale::RejectGroupSeparator

0x02

If this option is set, the string-to-number functions will fail if they encounter group separators in their input. The default is to accept numbers containing correctly placed group separators.

QLocale::OmitLeadingZeroInExponent

0x04

If this option is set, the number-to-string functions will not pad exponents with zeroes when printing floating point numbers in scientific notation. The default is to add one leading zero to single digit exponents.

QLocale::RejectLeadingZeroInExponent

0x08

If this option is set, the string-to-number functions will fail if they encounter an exponent padded with zeroes when parsing a floating point number in scientific notation. The default is to accept such padding.

QLocale::IncludeTrailingZeroesAfterDot

0x10

If this option is set, the number-to-string functions will pad numbers with zeroes to the requested precision in "g" or "most concise" mode, even if the number of significant digits is lower than the requested precision. The default is to omit trailing zeroes.

QLocale::RejectTrailingZeroesAfterDot

0x20

If this option is set, the string-to-number functions will fail if they encounter trailing zeroes after the decimal dot when parsing a number in scientific or decimal representation. The default is to accept trailing zeroes.

The NumberOptions type is a typedef for QFlags<NumberOption>. It stores an OR combination of NumberOption values.

See Also

[since 4.8] enum QLocale::QuotationStyle

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

Constant

Value

Description

QLocale::StandardQuotation

0

If this option is set, the standard quotation marks will be used to quote strings.

QLocale::AlternateQuotation

1

If this option is set, the alternate quotation marks will be used to quote strings.

This enum was introduced or modified in Qt 4.8.

See Also

See also quoteString()

enum QLocale::Script

This enumerated type is used to specify a script.

Constant

Value

QLocale::AnyScript

0

 

QLocale::AdlamScript

134

Since Qt 5.7

QLocale::AhomScript

128

Since Qt 5.7

QLocale::AnatolianHieroglyphsScript

129

Since Qt 5.7

QLocale::ArabicScript

1

 

QLocale::ArmenianScript

10

 

QLocale::AvestanScript

36

 

QLocale::BalineseScript

37

 

QLocale::BamumScript

38

 

QLocale::BassaVahScript

106

Since Qt 5.5

QLocale::BatakScript

39

 

QLocale::BengaliScript

11

 

QLocale::BhaiksukiScript

135

Since Qt 5.7

QLocale::BopomofoScript

40

 

QLocale::BrahmiScript

41

 

QLocale::BrailleScript

103

 

QLocale::BugineseScript

42

 

QLocale::BuhidScript

43

 

QLocale::CanadianAboriginalScript

44

 

QLocale::CarianScript

45

 

QLocale::CaucasianAlbanianScript

105

Since Qt 5.5

QLocale::ChakmaScript

46

 

QLocale::ChamScript

47

 

QLocale::CherokeeScript

12

 

QLocale::CopticScript

48

 

QLocale::CypriotScript

49

 

QLocale::CyrillicScript

2

 

QLocale::DeseretScript

3

 

QLocale::DevanagariScript

13

 

QLocale::DuployanScript

107

Since Qt 5.5

QLocale::EgyptianHieroglyphsScript

50

 

QLocale::ElbasanScript

108

Since Qt 5.5

QLocale::EthiopicScript

14

 

QLocale::FraserScript

51

 

QLocale::GeorgianScript

15

 

QLocale::GlagoliticScript

52

 

QLocale::GothicScript

53

 

QLocale::GranthaScript

109

Since Qt 5.5

QLocale::GreekScript

16

 

QLocale::GujaratiScript

17

 

QLocale::GurmukhiScript

4

 

QLocale::HanScript

54

 

QLocale::HangulScript

55

 

QLocale::HanunooScript

56

 

QLocale::HanWithBopomofoScript

140

Since Qt 5.7

QLocale::HatranScript

130

Since Qt 5.7

QLocale::HebrewScript

18

 

QLocale::HiraganaScript

104

 

QLocale::ImperialAramaicScript

57

 

QLocale::InscriptionalPahlaviScript

58

 

QLocale::InscriptionalParthianScript

59

 

QLocale::JamoScript

141

Since Qt 5.7

QLocale::JapaneseScript

19

 

QLocale::JavaneseScript

60

 

QLocale::KaithiScript

61

 

QLocale::KannadaScript

21

 

QLocale::KatakanaScript

62

 

QLocale::KayahLiScript

63

 

QLocale::KharoshthiScript

64

 

QLocale::KhmerScript

20

 

QLocale::KhojkiScript

111

Since Qt 5.5

QLocale::KhudawadiScript

125

Since Qt 5.5

QLocale::KoreanScript

22

 

QLocale::LannaScript

65

 

QLocale::LaoScript

23

 

QLocale::LatinScript

7

 

QLocale::LepchaScript

66

 

QLocale::LimbuScript

67

 

QLocale::LinearAScript

112

Since Qt 5.5

QLocale::LinearBScript

68

 

QLocale::LycianScript

69

 

QLocale::LydianScript

70

 

QLocale::MahajaniScript

113

Since Qt 5.5

QLocale::MalayalamScript

24

 

QLocale::MandaeanScript

71

 

QLocale::ManichaeanScript

114

Since Qt 5.5

QLocale::MarchenScript

136

Since Qt 5.7

QLocale::MeiteiMayekScript

72

 

QLocale::MendeKikakuiScript

115

Since Qt 5.5

QLocale::MeroiticScript

73

 

QLocale::MeroiticCursiveScript

74

 

QLocale::ModiScript

116

Since Qt 5.5

QLocale::MongolianScript

8

 

QLocale::MroScript

117

Since Qt 5.5

QLocale::MultaniScript

131

Since Qt 5.7

QLocale::MyanmarScript

25

 

QLocale::NabataeanScript

119

Since Qt 5.5

QLocale::NkoScript

75

 

QLocale::NewaScript

137

Since Qt 5.7

QLocale::NewTaiLueScript

76

 

QLocale::OghamScript

77

 

QLocale::OlChikiScript

78

 

QLocale::OldItalicScript

79

 

QLocale::OldHungarianScript

132

Since Qt 5.7

QLocale::OldNorthArabianScript

118

Since Qt 5.5

QLocale::OldPermicScript

122

Since Qt 5.5

QLocale::OldPersianScript

80

 

QLocale::OldSouthArabianScript

81

 

QLocale::OriyaScript

26

 

QLocale::OrkhonScript

82

 

QLocale::OsageScript

138

Since Qt 5.7

QLocale::OsmanyaScript

83

 

QLocale::PahawhHmongScript

110

Since Qt 5.5

QLocale::PalmyreneScript

120

Since Qt 5.5

QLocale::PauCinHauScript

121

Since Qt 5.5

QLocale::PhagsPaScript

84

 

QLocale::PhoenicianScript

85

 

QLocale::PollardPhoneticScript

86

 

QLocale::PsalterPahlaviScript

123

Since Qt 5.5

QLocale::RejangScript

87

 

QLocale::RunicScript

88

 

QLocale::SamaritanScript

89

 

QLocale::SaurashtraScript

90

 

QLocale::SharadaScript

91

 

QLocale::ShavianScript

92

 

QLocale::SiddhamScript

124

Since Qt 5.5

QLocale::SignWritingScript

133

Since Qt 5.7

QLocale::SimplifiedHanScript

5

same as SimplifiedChineseScript

QLocale::SimplifiedChineseScript

SimplifiedHanScript

same as SimplifiedHanScript

QLocale::SinhalaScript

32

 

QLocale::SoraSompengScript

93

 

QLocale::CuneiformScript

94

 

QLocale::SundaneseScript

95

 

QLocale::SylotiNagriScript

96

 

QLocale::SyriacScript

33

 

QLocale::TagalogScript

97

 

QLocale::TagbanwaScript

98

 

QLocale::TaiLeScript

99

 

QLocale::TaiVietScript

100

 

QLocale::TakriScript

101

 

QLocale::TamilScript

27

 

QLocale::TangutScript

139

Since Qt 5.7

QLocale::TeluguScript

28

 

QLocale::ThaanaScript

29

 

QLocale::ThaiScript

30

 

QLocale::TibetanScript

31

 

QLocale::TifinaghScript

9

 

QLocale::TirhutaScript

126

Since Qt 5.5

QLocale::TraditionalHanScript

6

same as TraditionalChineseScript

QLocale::TraditionalChineseScript

TraditionalHanScript

same as TraditionalHanScript

QLocale::UgariticScript

102

 

QLocale::VaiScript

35

 

QLocale::VarangKshitiScript

127

Since Qt 5.5

QLocale::YiScript

34

 
See Also

Member Function Documentation

 

[since 4.8] QString QLocale::toCurrencyString(float value, const QString &symbol = QString()) const

QString QLocale::toCurrencyString(float i, const QString &symbol, int precision) const

This function overloads toCurrencyString().

QLocale::QLocale()

Constructs a QLocale object initialized with the default locale. If no default locale was set using setDefault(), this locale will be the same as the one returned by system().

See Also

See also setDefault()

QLocale::QLocale(const QString &name)

Constructs a QLocale object with the specified name, which has the format "language[_script][_country][.codeset][@modifier]" or "C", where:

  • language is a lowercase, two-letter, ISO 639 language code (also some three-letter codes),

  • script is a titlecase, four-letter, ISO 15924 script code,

  • country is an uppercase, two-letter, ISO 3166 country code (also "419" as defined by United Nations),

  • and codeset and modifier are ignored.

The separator can be either underscore or a minus sign.

If the string violates the locale format, or language is not a valid ISO 639 code, the "C" locale is used instead. If country is not present, or is not a valid ISO 3166 code, the most appropriate country is chosen for the specified language.

The language, script and country codes are converted to their respective Language, Script and Country enums. After this conversion is performed, the constructor behaves exactly like QLocale(Country, Script, Language).

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

See Also

See also bcp47Name()

QLocale::QLocale(QLocale::Language language, QLocale::Country country = AnyCountry)

Constructs a QLocale object with the specified language and country.

  • If the language/country pair is found in the database, it is used.

  • If the language is found but the country is not, or if the country is AnyCountry, the language is used with the most appropriate available country (for example, Germany for German),

  • If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).

The language and country that are actually used can be queried using language() and country().

See Also

See also setDefault(), language(), country()

[since 4.8] QLocale::QLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country)

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

  • If the language/script/country is found in the database, it is used.

  • If both script is AnyScript and country is AnyCountry, the language is used with the most appropriate available script and country (for example, Germany for German),

  • If either script is AnyScript or country is AnyCountry, the language is used with the first locale that matches the given script and country.

  • If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).

The language, script and country that are actually used can be queried using language(), script() and country().

This function was introduced in Qt 4.8.

See Also

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

QLocale::QLocale(const QLocale &other)

Constructs a QLocale object as a copy of other.

QLocale::~QLocale()

Destructor

[since 4.5] QString QLocale::amText() const

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

This function was introduced in Qt 4.5.

See Also

See also pmText()

[since 4.8] QString QLocale::bcp47Name() const

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

Unlike the uiLanguages() the returned value of the bcp47Name() represents the locale name of the QLocale data but not the language the user-interface should be in.

This function tries to conform the locale name to BCP47.

This function was introduced in Qt 4.8.

See Also

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

[static] QLocale QLocale::c()

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

This locale is based on en_US but with various quirks of its own, such as simplified number formatting and its own date formatting. It implements the POSIX standards that describe the behavior of standard library functions of the "C" programming language.

Among other things, this means its collation order is based on the ASCII values of letters, so that (for case-sensitive sorting) all upper-case letters sort before any lower-case one (rather than each letter's upper- and lower-case forms sorting adjacent to one another, before the next letter's two forms).

See Also

See also system()

QLocale::Country QLocale::country() const

Returns the country of this locale.

See Also

[static] QString QLocale::countryToString(QLocale::Country country)

Returns a QString containing the name of country.

See Also

[since 4.8] QString QLocale::createSeparatedList(const QStringList &list) const

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

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format = CurrencySymbol) const

Returns a currency symbol according to the format.

This function was introduced in Qt 4.8.

[since 4.1] QString QLocale::dateFormat(QLocale::FormatType format = LongFormat) const

Returns the date format used for the current locale.

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

This function was introduced in Qt 4.1.

See Also

[since 4.4] QString QLocale::dateTimeFormat(QLocale::FormatType format = LongFormat) const

Returns the date time format used for the current locale.

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

This function was introduced in Qt 4.4.

See Also

[since 4.2] QString QLocale::dayName(int day, QLocale::FormatType type = LongFormat) const

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

This function was introduced in Qt 4.2.

See Also

[since 4.1] QChar QLocale::decimalPoint() const

Returns the decimal point character of this locale.

This function was introduced in Qt 4.1.

[since 4.1] QChar QLocale::exponential() const

Returns the exponential character of this locale.

This function was introduced in Qt 4.1.

[since 4.8] Qt::DayOfWeek QLocale::firstDayOfWeek() const

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

This function was introduced in Qt 4.8.

[since 5.10] QString QLocale::formattedDataSize(qint64 bytes, int precision = 2, QLocale::DataSizeFormats format = DataSizeIecFormat)

Converts a size in bytes to a human-readable localized string, comprising a number and a quantified unit. The quantifier is chosen such that the number is at least one, and as small as possible. For example if bytes is 16384, precision is 2, and format is DataSizeIecFormat (the default), this function returns "16.00 KiB"; for 1330409069609 bytes it returns "1.21 GiB"; and so on. If format is DataSizeIecFormat or DataSizeTraditionalFormat, the given number of bytes is divided by a power of 1024, with result less than 1024; for DataSizeSIFormat, it is divided by a power of 1000, with result less than 1000. DataSizeIecFormat uses the new IEC standard quantifiers Ki, Mi and so on, whereas DataSizeSIFormat uses the older SI quantifiers k, M, etc., and DataSizeTraditionalFormat abuses them.

This function was introduced in Qt 5.10.

[since 4.1] QChar QLocale::groupSeparator() const

Returns the group separator character of this locale.

This function was introduced in Qt 4.1.

QLocale::Language QLocale::language() const

Returns the language of this locale.

See Also

[static] QString QLocale::languageToString(QLocale::Language language)

Returns a QString containing the name of language.

See Also

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

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

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

Getting a list of locales suitable for Russia: QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::Russia);

This function was introduced in Qt 4.8.

[since 4.4] QLocale::MeasurementSystem QLocale::measurementSystem() const

Returns the measurement system for the locale.

This function was introduced in Qt 4.4.

[since 4.2] QString QLocale::monthName(int month, QLocale::FormatType type = LongFormat) const

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

This function was introduced in Qt 4.2.

See Also

QString QLocale::name() const

Returns the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.

Note that even if QLocale object was constructed with an explicit script, name() will not contain it for compatibility reasons. Use bcp47Name() instead if you need a full locale name.

See Also

See also QLocale(), language(), script(), country(), bcp47Name()

[since 4.8] QString QLocale::nativeCountryName() const

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

This function was introduced in Qt 4.8.

See Also

[since 4.8] QString QLocale::nativeLanguageName() const

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

This function was introduced in Qt 4.8.

See Also

[since 4.1] QChar QLocale::negativeSign() const

Returns the negative sign character of this locale.

This function was introduced in Qt 4.1.

[since 4.2] QLocale::NumberOptions QLocale::numberOptions() const

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

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

This function was introduced in Qt 4.2.

See Also

See also setNumberOptions()

[since 4.1] QChar QLocale::percent() const

Returns the percent character of this locale.

This function was introduced in Qt 4.1.

[since 4.5] QString QLocale::pmText() const

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

This function was introduced in Qt 4.5.

See Also

See also amText()

[since 4.5] QChar QLocale::positiveSign() const

Returns the positive sign character of this locale.

This function was introduced in Qt 4.5.

[since 4.8] QString QLocale::quoteString(const QString &str, QLocale::QuotationStyle style = StandardQuotation) const

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

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::quoteString(const QStringRef &str, QLocale::QuotationStyle style = StandardQuotation) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 4.8] QLocale::Script QLocale::script() const

Returns the script of this locale.

This function was introduced in Qt 4.8.

See Also

[static, since 4.8] QString QLocale::scriptToString(QLocale::Script script)

Returns a QString containing the name of script.

This function was introduced in Qt 4.8.

See Also

[static] void QLocale::setDefault(const QLocale &locale)

Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.

In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created.

This function is not reentrant.

See Also

See also system(), c()

[since 4.2] void QLocale::setNumberOptions(QLocale::NumberOptions options)

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

This function was introduced in Qt 4.2.

See Also

See also numberOptions()

[since 4.5] QString QLocale::standaloneDayName(int day, QLocale::FormatType type = LongFormat) const

Returns the localized name of the day (where 1 represents Monday, 2 represents Tuesday and so on) that is used as a standalone text, in the format specified by type.

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

This function was introduced in Qt 4.5.

See Also

[since 4.5] QString QLocale::standaloneMonthName(int month, QLocale::FormatType type = LongFormat) const

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

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

This function was introduced in Qt 4.5.

See Also

[since 5.6] void QLocale::swap(QLocale &other)

Swaps locale other with this locale. This operation is very fast and never fails.

This function was introduced in Qt 5.6.

[static] QLocale QLocale::system()

Returns a QLocale object initialized to the system locale.

On Windows and Mac, this locale will use the decimal/grouping characters and date/time formats specified in the system configuration panel.

See Also

See also c()

[since 4.7] Qt::LayoutDirection QLocale::textDirection() const

Returns the text direction of the language.

This function was introduced in Qt 4.7.

[since 4.1] QString QLocale::timeFormat(QLocale::FormatType format = LongFormat) const

Returns the time format used for the current locale.

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

This function was introduced in Qt 4.1.

See Also

[since 4.8] QString QLocale::toCurrencyString(qlonglong value, const QString &symbol = QString()) const

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

This function was introduced in Qt 4.8.

See Also

See also currencySymbol()

[since 4.8] QString QLocale::toCurrencyString(qulonglong value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::toCurrencyString(short value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::toCurrencyString(ushort value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::toCurrencyString(int value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::toCurrencyString(uint value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 4.8] QString QLocale::toCurrencyString(double value, const QString &symbol = QString()) const

This is an overloaded function.

This function was introduced in Qt 4.8.

[since 5.7] QString QLocale::toCurrencyString(double value, const QString &symbol, int precision) const

This function overloads toCurrencyString().

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

This function was introduced in Qt 5.7.

See Also

See also currencySymbol()

[since 4.4] QDate QLocale::toDate(const QString &string, QLocale::FormatType format = LongFormat) const

Parses the date string given in string and returns the date. The format of the date string is chosen according to the format parameter (see dateFormat()).

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

This function was introduced in Qt 4.4.

See Also

[since 4.4] QDate QLocale::toDate(const QString &string, const QString &format) const

Parses the date string given in string and returns the date. See QDate::fromString() for information on the expressions that can be used with this function.

This function searches month names and the names of the days of the week in the current locale.

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

This function was introduced in Qt 4.4.

See Also

[since 4.4] QDateTime QLocale::toDateTime(const QString &string, QLocale::FormatType format = LongFormat) const

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

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

This function was introduced in Qt 4.4.

See Also

[since 4.4] QDateTime QLocale::toDateTime(const QString &string, const QString &format) const

Parses the date/time string given in string and returns the time. See QDateTime::fromString() for information on the expressions that can be used with this function.

The month and day names used must be given in the user's local language.

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

This function was introduced in Qt 4.4.

See Also

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

Returns the double represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

 
Sélectionnez
bool ok;
double d;

QLocale c(QLocale::C);
d = c.toDouble( "1234.56", &amp;ok );  // ok == true, d == 1234.56
d = c.toDouble( "1,234.56", &amp;ok ); // ok == true, d == 1234.56
d = c.toDouble( "1234,56", &amp;ok );  // ok == false

QLocale german(QLocale::German);
d = german.toDouble( "1234,56", &amp;ok );  // ok == true, d == 1234.56
d = german.toDouble( "1.234,56", &amp;ok ); // ok == true, d == 1234.56
d = german.toDouble( "1234.56", &amp;ok );  // ok == false

d = german.toDouble( "1.234", &amp;ok );    // ok == true, d == 1234.0

Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.

This function ignores leading and trailing whitespace.

See Also

See also toFloat(), toInt(), toString()

[since 5.1] double QLocale::toDouble(const QStringRef &s, bool *ok = nullptr) const

Returns the double represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

 
Sélectionnez
bool ok;
double d;

QLocale c(QLocale::C);
d = c.toDouble( "1234.56", &amp;ok );  // ok == true, d == 1234.56
d = c.toDouble( "1,234.56", &amp;ok ); // ok == true, d == 1234.56
d = c.toDouble( "1234,56", &amp;ok );  // ok == false

QLocale german(QLocale::German);
d = german.toDouble( "1234,56", &amp;ok );  // ok == true, d == 1234.56
d = german.toDouble( "1.234,56", &amp;ok ); // ok == true, d == 1234.56
d = german.toDouble( "1234.56", &amp;ok );  // ok == false

d = german.toDouble( "1.234", &amp;ok );    // ok == true, d == 1234.0

Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toFloat(), toInt(), toString()

[since 5.10] double QLocale::toDouble(QStringView s, bool *ok = nullptr) const

Returns the double represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

Unlike QString::toDouble(), this function does not fall back to the "C" locale if the string cannot be interpreted in this locale.

 
Sélectionnez
bool ok;
double d;

QLocale c(QLocale::C);
d = c.toDouble(u"1234.56", &amp;ok);  // ok == true, d == 1234.56
d = c.toDouble(u"1,234.56", &amp;ok); // ok == true, d == 1234.56
d = c.toDouble(u"1234,56", &amp;ok);  // ok == false

QLocale german(QLocale::German);
d = german.toDouble(u"1234,56", &amp;ok);  // ok == true, d == 1234.56
d = german.toDouble(u"1.234,56", &amp;ok); // ok == true, d == 1234.56
d = german.toDouble(u"1234.56", &amp;ok);  // ok == false

d = german.toDouble(u"1.234", &amp;ok);    // ok == true, d == 1234.0

Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toFloat(), toInt(), toString()

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

Returns the float represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

This function ignores leading and trailing whitespace.

See Also

See also toDouble(), toInt(), toString()

[since 5.1] float QLocale::toFloat(const QStringRef &s, bool *ok = nullptr) const

Returns the float represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function does not fall back to the 'C' locale if the string cannot be interpreted in this locale.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toDouble(), toInt(), toString()

[since 5.10] float QLocale::toFloat(QStringView s, bool *ok = nullptr) const

Returns the float represented by the localized string s.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for any other reason (e.g. underflow).

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toDouble(), toInt(), toString()

int QLocale::toInt(const QString &s, bool *ok = nullptr) const

Returns the int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See Also

See also toUInt(), toString()

[since 5.1] int QLocale::toInt(const QStringRef &s, bool *ok = nullptr) const

Returns the int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toUInt(), toString()

[since 5.10] int QLocale::toInt(QStringView s, bool *ok = nullptr) const

Returns the int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toUInt(), toString()

qlonglong QLocale::toLongLong(const QString &s, bool *ok = nullptr) const

Returns the long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See Also

See also toInt(), toULongLong(), toDouble(), toString()

[since 5.1] qlonglong QLocale::toLongLong(const QStringRef &s, bool *ok = nullptr) const

Returns the long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toInt(), toULongLong(), toDouble(), toString()

[since 5.10] qlonglong QLocale::toLongLong(QStringView s, bool *ok = nullptr) const

Returns the long long int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toInt(), toULongLong(), toDouble(), toString()

[since 4.8] QString QLocale::toLower(const QString &str) const

Returns a lowercase copy of str.

If Qt Core is using the ICU libraries, they will be used to perform the transformation according to the rules of the current locale. Otherwise the conversion may be done in a platform-dependent manner, with QString::toLower() as a generic fallback.

This function was introduced in Qt 4.8.

See Also

See also QString::toLower()

short QLocale::toShort(const QString &s, bool *ok = nullptr) const

Returns the short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See Also

See also toUShort(), toString()

[since 5.1] short QLocale::toShort(const QStringRef &s, bool *ok = nullptr) const

Returns the short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toUShort(), toString()

[since 5.10] short QLocale::toShort(QStringView s, bool *ok = nullptr) const

Returns the short int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toUShort(), toString()

QString QLocale::toString(qlonglong i) const

Returns a localized string representation of i.

See Also

See also toLongLong()

QString QLocale::toString(qulonglong i) const

This is an overloaded function.

See Also

See also toULongLong()

QString QLocale::toString(short i) const

This is an overloaded function.

See Also

See also toShort()

QString QLocale::toString(ushort i) const

This is an overloaded function.

See Also

See also toUShort()

QString QLocale::toString(int i) const

This is an overloaded function.

See Also

See also toInt()

QString QLocale::toString(uint i) const

This is an overloaded function.

See Also

See also toUInt()

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

This is an overloaded function.

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

See Also

See also toDouble()

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

This is an overloaded function.

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

See Also

See also toDouble()

QString QLocale::toString(const QDate &date, const QString &format) const

Returns a localized string representation of the given date in the specified format. If format is an empty string, an empty string is returned.

See Also

See also QDate::toString()

QString QLocale::toString(const QTime &time, const QString &format) const

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

See Also

See also QTime::toString()

[since 4.4] QString QLocale::toString(const QDateTime &dateTime, const QString &format) const

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

This function was introduced in Qt 4.4.

See Also

[since 5.10] QString QLocale::toString(const QDate &date, QStringView format) const

Returns a localized string representation of the given date in the specified format. If format is an empty string, an empty string is returned.

This function was introduced in Qt 5.10.

See Also

See also QDate::toString()

[since 5.10] QString QLocale::toString(const QTime &time, QStringView format) const

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

This function was introduced in Qt 5.10.

See Also

See also QTime::toString()

[since 5.10] QString QLocale::toString(const QDateTime &dateTime, QStringView format) const

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

This function was introduced in Qt 5.10.

See Also

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

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

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

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

[since 4.4] QString QLocale::toString(const QDateTime &dateTime, QLocale::FormatType format = LongFormat) const

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

This function was introduced in Qt 4.4.

[since 4.4] QTime QLocale::toTime(const QString &string, QLocale::FormatType format = LongFormat) const

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

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

This function was introduced in Qt 4.4.

See Also

[since 4.4] QTime QLocale::toTime(const QString &string, const QString &format) const

Parses the time string given in string and returns the time. See QTime::fromString() for information on what is a valid format string.

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

This function was introduced in Qt 4.4.

See Also

uint QLocale::toUInt(const QString &s, bool *ok = nullptr) const

Returns the unsigned int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See Also

See also toInt(), toString()

[since 5.1] uint QLocale::toUInt(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toInt(), toString()

[since 5.10] uint QLocale::toUInt(QStringView s, bool *ok = nullptr) const

Returns the unsigned int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toInt(), toString()

qulonglong QLocale::toULongLong(const QString &s, bool *ok = nullptr) const

Returns the unsigned long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See Also

See also toLongLong(), toInt(), toDouble(), toString()

[since 5.1] qulonglong QLocale::toULongLong(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned long long int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toLongLong(), toInt(), toDouble(), toString()

[since 5.10] qulonglong QLocale::toULongLong(QStringView s, bool *ok = nullptr) const

Returns the unsigned long long int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toLongLong(), toInt(), toDouble(), toString()

ushort QLocale::toUShort(const QString &s, bool *ok = nullptr) const

Returns the unsigned short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

See Also

See also toShort(), toString()

[since 5.1] ushort QLocale::toUShort(const QStringRef &s, bool *ok = nullptr) const

Returns the unsigned short int represented by the localized string s.

If the conversion fails the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.1.

See Also

See also toShort(), toString()

[since 5.10] ushort QLocale::toUShort(QStringView s, bool *ok = nullptr) const

Returns the unsigned short int represented by the localized string s.

If the conversion fails, the function returns 0.

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

This function ignores leading and trailing whitespace.

This function was introduced in Qt 5.10.

See Also

See also toShort(), toString()

[since 4.8] QString QLocale::toUpper(const QString &str) const

Returns an uppercase copy of str.

If Qt Core is using the ICU libraries, they will be used to perform the transformation according to the rules of the current locale. Otherwise the conversion may be done in a platform-dependent manner, with QString::toUpper() as a generic fallback.

This function was introduced in Qt 4.8.

See Also

See also QString::toUpper()

[since 4.8] QStringList QLocale::uiLanguages() const

Returns an ordered list of locale names for translation purposes in preference order (like "en-Latn-US", "en-US", "en").

The return value represents locale names that the user expects to see the UI translation in.

Most like you do not need to use this function directly, but just pass the QLocale object to the QTranslator::load() function.

The first item in the list is the most preferred one.

This function was introduced in Qt 4.8.

See Also

See also QTranslator, bcp47Name()

[since 4.8] QList<Qt::DayOfWeek> QLocale::weekdays() const

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

This function was introduced in Qt 4.8.

[since 4.1] QChar QLocale::zeroDigit() const

Returns the zero digit character of this locale.

This function was introduced in Qt 4.1.

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)

Assigns other to this QLocale object and returns a reference to this QLocale 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.

Related Non-Members

 

[since 5.6] uint qHash(const QLocale &key, uint seed = 0)

Returns the hash value for key, using seed to seed the calculation.

This function was introduced in Qt 5.6.

Obsolete Members for QLocale

The following members of class QLocale are deprecated. We strongly advise against using them in new code.

Obsolete Member Function Documentation

 
[static, since 4.3] QList<QLocale::Country> QLocale::countriesForLanguage(QLocale::Language language)

This function is deprecated. We strongly advise against using it in new code.

Returns the list of countries that have entries for language in Qt's locale database. If the result is an empty list, then language is not represented in Qt's locale database.

This function was introduced in Qt 4.3.

See Also

See also matchingLocales()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+