QLocale#

The QLocale class converts between numbers and their string representations in various languages. More

Synopsis#

Functions#

Static functions#

Detailed Description#

QLocale is constructed for a specified language, optional script and territory. It offers various facilities for formatting data as text, localized appropriately, and for reading data out of localized text.

Example:

egyptian = QLocale(QLocale.Arabic, QLocale.Egypt)
s1 = egyptian.toString(1.571429E+07, 'e')
s2 = egyptian.toString(10)
d = egyptian.toDouble(s1)
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.

  • 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:

ok = bool()
d = float()
QLocale.setDefault(QLocale.C) # uses '.' as a decimal point
cLocale = QLocale()
d = cLocale.toDouble("1234,56", ok) # ok == false, d == 0
d = cLocale.toDouble("1234.56", ok) # ok == true, d == 1234.56
QLocale.setDefault(QLocale.German) # uses ',' as a decimal point
german = QLocale()
d = german.toDouble("1234,56", ok) # ok == true, d == 1234.56
d = german.toDouble("1234.56", ok) # ok == false, d == 0
QLocale.setDefault(QLocale.English)
# Default locale now uses ',' as a group separator.
str = QString("%1 %L2 %L3").arg(12345).arg(12345).arg(12345, 0, 16)
# str == "12345 12,345 3039"

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

korean = QLocale("ko")
swiss = QLocale("de_CH")

This constructor reads the language, script and/or territory from the given name, accepting either uderscore or dash as separator (and ignoring any trailing .codeset or @variant suffix).

Note

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

QLocale ‘s data is based on Common Locale Data Repository v40.

Matching combinations of language, script and territory#

QLocale has data, derived from CLDR, for many combinations of language, script and territory, but not all. If it is constructed with all three of these key values specified (treating AnyLanguage, AnyScript or AnyTerritory as unspecified) and QLocale has data for the given combination, this data is used. Otherwise, QLocale does its best to find a sensible combination of language, script and territory, for which it does have data, that matches those that were specified.

The CLDR provides tables of likely combinations, which are used to fill in any unspecified key or keys; if QLocale has data for the result of such a likely combination, that is used. If no language is specified, and none can be determined from script and territory, or if QLocale has no data for the language, the “C” locale (when reading the keys from a string) or default locale (otherwise) is used.

When QLocale has no data for the keys specified, with likely keys filled in where unspecified, but does have data for the resulting language, a fall-back is sought, based on ignoring either territory, script or both (in that order). This results in a QLocale which may not match what was asked for, but provides localization that’s as suitable as the available data permits, for the keys specified.

Use language() , script() and territory() to determine the actual keys used.

See also

arg() locale()

class PySide6.QtCore.QLocale#

PySide6.QtCore.QLocale(language, territory)

PySide6.QtCore.QLocale(language[, script=QLocale.Script.AnyScript[, territory=QLocale.Country.AnyTerritory]])

PySide6.QtCore.QLocale(name)

PySide6.QtCore.QLocale(other)

PySide6.QtCore.QLocale(name)

Parameters

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

Constructs a QLocale object for the specified language and territory.

If there is more than one script in use for this combination, a likely script will be selected. If QLocale has no data for the specified language, the default locale is used. If QLocale has no data for the specified combination of language and territory, an alternative territory may be used instead.

See also

setDefault() Matching combinations of language, script and territory

Constructs a QLocale object for the specified language, script and territory.

If QLocale does not have data for the given combination, it will find data for as good a match as it can. It falls back on the default locale if

  • language is AnyLanguage and no language can be inferred from script and territory

  • QLocale has no data for the language, either given as language or inferred as above.

See also

setDefault() Matching combinations of language, script and territory

Constructs a QLocale object with the specified name.

The name has the format “language[_script][_territory][.codeset][@modifier]” or “C”, where:

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

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

  • territory is an uppercase, two-letter, ISO 3166 territory code (some numeric codes are also recognized), and

  • codeset and modifier are ignored.

The separator can be either underscore '_' (U+005F, “low line”) or a dash '-' (U+002D, “hyphen-minus”). If QLocale has no data for the specified combination of language, script, and territory, then it uses the most suitable match it can find instead. If the string violates the locale format, or no suitable data can be found for the specified keys, the “C” locale is used instead.

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

See also

bcp47Name() Matching combinations of language, script and territory

Constructs a QLocale object as a copy of other.

This is an overloaded function.

PySide6.QtCore.QLocale.Language#

This enumerated type is used to specify a language.

Constant

Description

QLocale.AnyLanguage

QLocale.C

A simplified English locale; see c()

QLocale.Abkhazian

QLocale.Afan

Obsolete, please use Oromo

QLocale.Afar

QLocale.Afrikaans

QLocale.Aghem

QLocale.Akan

QLocale.Akkadian

Since Qt 5.1

QLocale.Akoose

Since Qt 5.3

QLocale.Albanian

QLocale.AmericanSignLanguage

Since Qt 5.7

QLocale.Amharic

QLocale.AncientEgyptian

Since Qt 5.1

QLocale.AncientGreek

Since Qt 5.1

QLocale.Arabic

QLocale.Aragonese

Since Qt 5.1

QLocale.Aramaic

Since Qt 5.1

QLocale.Armenian

QLocale.Assamese

QLocale.Asturian

QLocale.Asu

QLocale.Atsam

QLocale.Avaric

QLocale.Avestan

QLocale.Aymara

QLocale.Azerbaijani

QLocale.Bafia

QLocale.Balinese

Since Qt 5.1

QLocale.Bambara

QLocale.Bamun

Since Qt 5.1

QLocale.Bangla

Since Qt 6.0

QLocale.Basaa

QLocale.Bashkir

QLocale.Basque

QLocale.BatakToba

Since Qt 5.1

QLocale.Belarusian

QLocale.Bemba

QLocale.Bena

QLocale.Bengali

Obsolete, please use Bangla

QLocale.Bhojpuri

Since Qt 5.7

QLocale.Bhutani

Obsolete, please use Dzongkha

QLocale.Bislama

QLocale.Blin

QLocale.Bodo

QLocale.Bosnian

QLocale.Breton

QLocale.Buginese

Since Qt 5.1

QLocale.Bulgarian

QLocale.Burmese

QLocale.Byelorussian

Obsolete, please use Belarusian

QLocale.Cambodian

Obsolete, please use Khmer

QLocale.Cantonese

Since Qt 5.7

QLocale.Catalan

QLocale.Cebuano

Since Qt 5.14

QLocale.CentralAtlasTamazight

Since Qt 6.0

QLocale.CentralKurdish

Since Qt 5.5

QLocale.CentralMoroccoTamazight

Obsolete, please use

QLocale.Chakma

Since Qt 5.1

QLocale.Chamorro

QLocale.Chechen

QLocale.Cherokee

QLocale.Chewa

Obsolete, please use Nyanja

QLocale.Chickasaw

Since Qt 5.14

QLocale.Chiga

QLocale.Chinese

(Mandarin)

QLocale.Church

QLocale.Chuvash

QLocale.Colognian

QLocale.Coptic

Since Qt 5.1

QLocale.Cornish

QLocale.Corsican

QLocale.Cree

QLocale.Croatian

QLocale.Czech

QLocale.Danish

QLocale.Divehi

QLocale.Dogri

Since Qt 5.1

QLocale.Duala

QLocale.Dutch

QLocale.Dzongkha

QLocale.Embu

QLocale.English

QLocale.Erzya

Since Qt 5.14

QLocale.Esperanto

QLocale.Estonian

QLocale.Ewe

QLocale.Ewondo

QLocale.Faroese

QLocale.Fijian

QLocale.Filipino

QLocale.Finnish

QLocale.French

QLocale.Frisian

same as

QLocale.Friulian

QLocale.Fulah

QLocale.Ga

QLocale.Gaelic

QLocale.Galician

QLocale.Ganda

QLocale.Geez

QLocale.Georgian

QLocale.German

QLocale.Gothic

Since Qt 5.1

QLocale.Greek

QLocale.Greenlandic

Obsolete, please use Kalaallisut

QLocale.Guarani

QLocale.Gujarati

QLocale.Gusii

QLocale.Haitian

QLocale.Hausa

QLocale.Hawaiian

QLocale.Hebrew

QLocale.Herero

QLocale.Hindi

QLocale.HiriMotu

QLocale.Hungarian

QLocale.Icelandic

QLocale.Ido

Since Qt 5.12

QLocale.Igbo

QLocale.InariSami

Since Qt 5.5

QLocale.Indonesian

QLocale.Ingush

Since Qt 5.1

QLocale.Interlingua

QLocale.Interlingue

QLocale.Inuktitut

QLocale.Inupiak

Obsolete, please use Inupiaq

QLocale.Inupiaq

Since 6.0

QLocale.Irish

QLocale.Italian

QLocale.Japanese

QLocale.Javanese

QLocale.Jju

QLocale.JolaFonyi

QLocale.Kabuverdianu

QLocale.Kabyle

QLocale.Kaingang

Since 6.3

QLocale.Kako

QLocale.Kalaallisut

Since Qt 6.0

QLocale.Kalenjin

QLocale.Kamba

QLocale.Kannada

QLocale.Kanuri

QLocale.Kashmiri

QLocale.Kazakh

QLocale.Kenyang

Since Qt 5.5

QLocale.Khmer

QLocale.Kiche

Since Qt 5.5

QLocale.Kikuyu

QLocale.Kinyarwanda

QLocale.Kirghiz

Obsolete, please use Kyrgyz

QLocale.Komi

QLocale.Kongo

QLocale.Konkani

QLocale.Korean

QLocale.Koro

QLocale.KoyraboroSenni

QLocale.KoyraChiini

QLocale.Kpelle

QLocale.Kuanyama

Since 6.0

QLocale.Kurdish

QLocale.Kurundi

Obsolete, please use Rundi

QLocale.Kwanyama

Obsolete, please use Kuanyama

QLocale.Kwasio

QLocale.Kyrgyz

Since 6.0

QLocale.Lakota

Since Qt 5.3

QLocale.Langi

QLocale.Lao

QLocale.Latin

QLocale.Latvian

QLocale.Lezghian

Since Qt 5.5

QLocale.Limburgish

QLocale.Lingala

QLocale.LiteraryChinese

Since Qt 5.7

QLocale.Lithuanian

QLocale.Lojban

Since Qt 5.12

QLocale.LowerSorbian

Since Qt 5.5

QLocale.LowGerman

QLocale.LubaKatanga

QLocale.LuleSami

Since Qt 5.5

QLocale.Luo

QLocale.Luxembourgish

QLocale.Luyia

QLocale.Macedonian

QLocale.Machame

QLocale.Maithili

Since Qt 5.5

QLocale.MakhuwaMeetto

QLocale.Makonde

QLocale.Malagasy

QLocale.Malay

QLocale.Malayalam

QLocale.Maltese

QLocale.Mandingo

Since Qt 5.1

QLocale.Manipuri

Since Qt 5.1

QLocale.Manx

QLocale.Maori

QLocale.Mapuche

Since Qt 5.5

QLocale.Marathi

QLocale.Marshallese

QLocale.Masai

QLocale.Mazanderani

Since Qt 5.7

QLocale.Mende

Since Qt 5.5

QLocale.Meru

QLocale.Meta

QLocale.Mohawk

Since Qt 5.5

QLocale.Mongolian

QLocale.Morisyen

QLocale.Mundang

QLocale.Muscogee

Since Qt 5.14

QLocale.Nama

QLocale.NauruLanguage

QLocale.Navaho

Obsolete, please use Navajo

QLocale.Navajo

Since 6.0

QLocale.Ndonga

QLocale.Nepali

QLocale.Newari

Since Qt 5.7

QLocale.Ngiemboon

QLocale.Nheengatu

Since 6.3

QLocale.NigerianPidgin

Since Qt 6.0

QLocale.Ngomba

QLocale.Nko

Since Qt 5.5

QLocale.NorthernLuri

Since Qt 5.7

QLocale.NorthernSami

QLocale.NorthernSotho

QLocale.NorthNdebele

QLocale.NorwegianBokmal

QLocale.NorwegianNynorsk

QLocale.Nuer

QLocale.Nyanja

QLocale.Nyankole

QLocale.Occitan

QLocale.Odia

Since 6.0

QLocale.Ojibwa

QLocale.OldIrish

Since Qt 5.1

QLocale.OldNorse

Since Qt 5.1

QLocale.OldPersian

Since Qt 5.1

QLocale.Oriya

Obsolete, please use Odia

QLocale.Oromo

QLocale.Osage

Since Qt 5.7

QLocale.Ossetic

QLocale.Pahlavi

Since Qt 5.1

QLocale.Palauan

Since Qt 5.7

QLocale.Pali

QLocale.Papiamento

Since Qt 5.7

QLocale.Pashto

QLocale.Persian

QLocale.Phoenician

Since Qt 5.1

QLocale.Polish

QLocale.Portuguese

QLocale.Prussian

Since Qt 5.5

QLocale.Punjabi

QLocale.Quechua

QLocale.RhaetoRomance

Obsolete, please use Romansh

QLocale.Romanian

QLocale.Romansh

QLocale.Rombo

QLocale.Rundi

QLocale.Russian

QLocale.Rwa

QLocale.Saho

QLocale.Sakha

QLocale.Samburu

QLocale.Samoan

QLocale.Sango

QLocale.Sangu

QLocale.Sanskrit

QLocale.Santali

Since Qt 5.1

QLocale.Sardinian

QLocale.Saurashtra

Since Qt 5.1

QLocale.Sena

QLocale.Serbian

QLocale.Shambala

QLocale.Shona

QLocale.SichuanYi

QLocale.Sicilian

Since Qt 5.12

QLocale.Sidamo

QLocale.Silesian

Since Qt 5.14

QLocale.Sindhi

QLocale.Sinhala

QLocale.SkoltSami

Since Qt 5.5

QLocale.Slovak

QLocale.Slovenian

QLocale.Soga

QLocale.Somali

QLocale.SouthernKurdish

Since Qt 5.12

QLocale.SouthernSami

Since Qt 5.5

QLocale.SouthernSotho

QLocale.SouthNdebele

QLocale.Spanish

QLocale.StandardMoroccanTamazight

Since Qt 5.3

QLocale.Sundanese

QLocale.Swahili

QLocale.Swati

QLocale.Swedish

QLocale.SwissGerman

QLocale.Syriac

QLocale.Tachelhit

QLocale.Tahitian

QLocale.TaiDam

Since Qt 5.1

QLocale.Taita

QLocale.Tajik

QLocale.Tamil

QLocale.Taroko

QLocale.Tasawaq

QLocale.Tatar

QLocale.Telugu

QLocale.Teso

QLocale.Thai

QLocale.Tibetan

QLocale.Tigre

QLocale.Tigrinya

QLocale.TokelauLanguage

Since Qt 5.7

QLocale.TokPisin

Since Qt 5.7

QLocale.Tongan

QLocale.Tsonga

QLocale.Tswana

QLocale.Turkish

QLocale.Turkmen

QLocale.TuvaluLanguage

Since Qt 5.7

QLocale.Tyap

QLocale.Ugaritic

Since Qt 5.1

QLocale.Uighur

Obsolete, please use Uyghur

QLocale.Uigur

Obsolete, please use Uyghur

QLocale.Ukrainian

QLocale.UpperSorbian

Since Qt 5.5

QLocale.Urdu

QLocale.Uyghur

Since 6.0

QLocale.Uzbek

QLocale.Vai

QLocale.Venda

QLocale.Vietnamese

QLocale.Volapuk

QLocale.Vunjo

QLocale.Walamo

Obsolete, please use Wolaytta

QLocale.Walloon

QLocale.Walser

QLocale.Warlpiri

Since Qt 5.5

QLocale.Welsh

QLocale.WesternBalochi

Since Qt 5.12

QLocale.WesternFrisian

same as Frisian

QLocale.Wolaytta

Since 6.0

QLocale.Wolof

QLocale.Xhosa

QLocale.Yangben

QLocale.Yiddish

QLocale.Yoruba

QLocale.Zarma

QLocale.Zhuang

QLocale.Zulu

PySide6.QtCore.QLocale.Script#

This enumerated type is used to specify a script.

Constant

Description

QLocale.AnyScript

QLocale.AdlamScript

Since Qt 5.7

QLocale.AhomScript

Since Qt 5.7

QLocale.AnatolianHieroglyphsScript

Since Qt 5.7

QLocale.ArabicScript

QLocale.ArmenianScript

QLocale.AvestanScript

Since Qt 5.1

QLocale.BalineseScript

Since Qt 5.1

QLocale.BamumScript

Since Qt 5.1

QLocale.BanglaScript

Since 6.0

QLocale.BassaVahScript

Since Qt 5.5

QLocale.BatakScript

Since Qt 5.1

QLocale.BengaliScript

Obsolete, please use

QLocale.BhaiksukiScript

Since Qt 5.7

QLocale.BopomofoScript

Since Qt 5.1

QLocale.BrahmiScript

Since Qt 5.1

QLocale.BrailleScript

Since Qt 5.1

QLocale.BugineseScript

Since Qt 5.1

QLocale.BuhidScript

Since Qt 5.1

QLocale.CanadianAboriginalScript

Since Qt 5.1

QLocale.CarianScript

Since Qt 5.1

QLocale.CaucasianAlbanianScript

Since Qt 5.5

QLocale.ChakmaScript

Since Qt 5.1

QLocale.ChamScript

Since Qt 5.1

QLocale.CherokeeScript

QLocale.CopticScript

Since Qt 5.1

QLocale.CuneiformScript

Since Qt 5.1

QLocale.CypriotScript

Since Qt 5.1

QLocale.CyrillicScript

QLocale.DeseretScript

Since Qt 5.1

QLocale.DevanagariScript

QLocale.DuployanScript

Since Qt 5.5

QLocale.EgyptianHieroglyphsScript

Since Qt 5.1

QLocale.ElbasanScript

Since Qt 5.5

QLocale.EthiopicScript

QLocale.FraserScript

Since Qt 5.1

QLocale.GeorgianScript

QLocale.GlagoliticScript

Since Qt 5.1

QLocale.GothicScript

Since Qt 5.1

QLocale.GranthaScript

Since Qt 5.5

QLocale.GreekScript

QLocale.GujaratiScript

QLocale.GurmukhiScript

QLocale.HangulScript

Since Qt 5.1

QLocale.HanScript

Since Qt 5.1

QLocale.HanunooScript

Since Qt 5.1

QLocale.HanWithBopomofoScript

Since Qt 5.7

QLocale.HatranScript

Since Qt 5.7

QLocale.HebrewScript

QLocale.HiraganaScript

Since Qt 5.1

QLocale.ImperialAramaicScript

Since Qt 5.1

QLocale.InscriptionalPahlaviScript

Since Qt 5.1

QLocale.InscriptionalParthianScript

Since Qt 5.1

QLocale.JamoScript

Since Qt 5.7

QLocale.JapaneseScript

QLocale.JavaneseScript

Since Qt 5.1

QLocale.KaithiScript

Since Qt 5.1

QLocale.KannadaScript

QLocale.KatakanaScript

Since Qt 5.1

QLocale.KayahLiScript

Since Qt 5.1

QLocale.KharoshthiScript

Since Qt 5.1

QLocale.KhmerScript

Since Qt 5.1

QLocale.KhojkiScript

Since Qt 5.5

QLocale.KhudawadiScript

Since Qt 5.5

QLocale.KoreanScript

QLocale.LannaScript

Since Qt 5.1

QLocale.LaoScript

QLocale.LatinScript

QLocale.LepchaScript

Since Qt 5.1

QLocale.LimbuScript

Since Qt 5.1

QLocale.LinearAScript

Since Qt 5.5

QLocale.LinearBScript

Since Qt 5.1

QLocale.LycianScript

Since Qt 5.1

QLocale.LydianScript

Since Qt 5.1

QLocale.MahajaniScript

Since Qt 5.5

QLocale.MalayalamScript

QLocale.MandaeanScript

Since Qt 5.1

QLocale.ManichaeanScript

Since Qt 5.5

QLocale.MarchenScript

Since Qt 5.7

QLocale.MeiteiMayekScript

Since Qt 5.1

QLocale.MendeScript

Since Qt 6.0

QLocale.MendeKikakuiScript

Obsolete, please use

QLocale.MeroiticCursiveScript

Since Qt 5.1

QLocale.MeroiticScript

Since Qt 5.1

QLocale.ModiScript

Since Qt 5.5

QLocale.MongolianScript

QLocale.MroScript

Since Qt 5.5

QLocale.MultaniScript

Since Qt 5.7

QLocale.MyanmarScript

QLocale.NabataeanScript

Since Qt 5.5

QLocale.NewaScript

Since Qt 5.7

QLocale.NewTaiLueScript

Since Qt 5.1

QLocale.NkoScript

Since Qt 5.1

QLocale.OghamScript

Since Qt 5.1

QLocale.OlChikiScript

Since Qt 5.1

QLocale.OldHungarianScript

Since Qt 5.7

QLocale.OldItalicScript

Since Qt 5.1

QLocale.OldNorthArabianScript

Since Qt 5.5

QLocale.OldPermicScript

Since Qt 5.5

QLocale.OldPersianScript

Since Qt 5.1

QLocale.OldSouthArabianScript

Since Qt 5.1

QLocale.OdiaScript

Since 6.0

QLocale.OriyaScript

Obsolete, please use

QLocale.OrkhonScript

Since Qt 5.1

QLocale.OsageScript

Since Qt 5.7

QLocale.OsmanyaScript

Since Qt 5.1

QLocale.PahawhHmongScript

Since Qt 5.5

QLocale.PalmyreneScript

Since Qt 5.5

QLocale.PauCinHauScript

Since Qt 5.5

QLocale.PhagsPaScript

Since Qt 5.1

QLocale.PhoenicianScript

Since Qt 5.1

QLocale.PollardPhoneticScript

Since Qt 5.1

QLocale.PsalterPahlaviScript

Since Qt 5.5

QLocale.RejangScript

Since Qt 5.1

QLocale.RunicScript

Since Qt 5.1

QLocale.SamaritanScript

Since Qt 5.1

QLocale.SaurashtraScript

Since Qt 5.1

QLocale.SharadaScript

Since Qt 5.1

QLocale.ShavianScript

Since Qt 5.1

QLocale.SiddhamScript

Since Qt 5.5

QLocale.SignWritingScript

Since Qt 5.7

QLocale.SimplifiedChineseScript

same as

QLocale.SimplifiedHanScript

same as

QLocale.SinhalaScript

QLocale.SoraSompengScript

Since Qt 5.1

QLocale.SundaneseScript

Since Qt 5.1

QLocale.SylotiNagriScript

Since Qt 5.1

QLocale.SyriacScript

QLocale.TagalogScript

Since Qt 5.1

QLocale.TagbanwaScript

Since Qt 5.1

QLocale.TaiLeScript

Since Qt 5.1

QLocale.TaiVietScript

Since Qt 5.1

QLocale.TakriScript

Since Qt 5.1

QLocale.TamilScript

QLocale.TangutScript

Since Qt 5.7

QLocale.TeluguScript

QLocale.ThaanaScript

QLocale.ThaiScript

QLocale.TibetanScript

QLocale.TifinaghScript

QLocale.TirhutaScript

Since Qt 5.5

QLocale.TraditionalChineseScript

same as

QLocale.TraditionalHanScript

same as

QLocale.UgariticScript

Since Qt 5.1

QLocale.VaiScript

QLocale.VarangKshitiScript

Since Qt 5.5

QLocale.YiScript

New in version 4.8.

PySide6.QtCore.QLocale.Country#

This enumerated type is used to identify a territory.

An individual territory may be a province of a country, a country (by far the most common case) or a larger geographic entity, to which some localization details are specific.

Constant

Description

QLocale.AnyCountry

Osbolete alias for AnyTerritory

QLocale.AnyTerritory

Since 6.2

QLocale.Afghanistan

QLocale.AlandIslands

QLocale.Albania

QLocale.Algeria

QLocale.AmericanSamoa

QLocale.Andorra

QLocale.Angola

QLocale.Anguilla

QLocale.Antarctica

QLocale.AntiguaAndBarbuda

QLocale.Argentina

QLocale.Armenia

QLocale.Aruba

QLocale.AscensionIsland

QLocale.Australia

QLocale.Austria

QLocale.Azerbaijan

QLocale.Bahamas

QLocale.Bahrain

QLocale.Bangladesh

QLocale.Barbados

QLocale.Belarus

QLocale.Belgium

QLocale.Belize

QLocale.Benin

QLocale.Bermuda

QLocale.Bhutan

QLocale.Bolivia

QLocale.Bonaire

QLocale.BosniaAndHerzegowina

Obsolete, use BosniaAndHerzegovina instead

QLocale.BosniaAndHerzegovina

Since 6.0

QLocale.Botswana

QLocale.BouvetIsland

QLocale.Brazil

QLocale.BritishIndianOceanTerritory

QLocale.BritishVirginIslands

QLocale.Brunei

QLocale.Bulgaria

QLocale.BurkinaFaso

QLocale.Burundi

QLocale.Cambodia

QLocale.Cameroon

QLocale.Canada

QLocale.CanaryIslands

QLocale.CaribbeanNetherlands

QLocale.CapeVerde

QLocale.CaymanIslands

QLocale.CentralAfricanRepublic

QLocale.CeutaAndMelilla

QLocale.Chad

QLocale.Chile

QLocale.China

QLocale.ChristmasIsland

QLocale.ClippertonIsland

QLocale.CocosIslands

QLocale.Colombia

QLocale.Comoros

QLocale.CongoBrazzaville

QLocale.CongoKinshasa

QLocale.CookIslands

QLocale.CostaRica

QLocale.Croatia

QLocale.Cuba

QLocale.Curacao

Since Qt 6.0

QLocale.CuraSao

Obsolete, use Curacao instead

QLocale.Cyprus

QLocale.Czechia

Since 6.0

QLocale.CzechRepublic

Obsolete, use Czechia instead

QLocale.DemocraticRepublicOfCongo

Obsolete, use CongoKinshasa instead

QLocale.DemocraticRepublicOfKorea

Obsolete, use NorthKorea instead

QLocale.Denmark

QLocale.DiegoGarcia

QLocale.Djibouti

QLocale.Dominica

QLocale.DominicanRepublic

QLocale.EastTimor

QLocale.Ecuador

QLocale.Egypt

QLocale.ElSalvador

QLocale.EquatorialGuinea

QLocale.Eritrea

QLocale.Estonia

QLocale.Eswatini

QLocale.Ethiopia

QLocale.EuropeanUnion

Since Qt 5.7

QLocale.Europe

Since Qt 5.12

QLocale.FalklandIslands

QLocale.FaroeIslands

QLocale.Fiji

QLocale.Finland

QLocale.France

QLocale.FrenchGuiana

QLocale.FrenchPolynesia

QLocale.FrenchSouthernTerritories

QLocale.Gabon

QLocale.Gambia

QLocale.Georgia

QLocale.Germany

QLocale.Ghana

QLocale.Gibraltar

QLocale.Greece

QLocale.Greenland

QLocale.Grenada

QLocale.Guadeloupe

QLocale.Guam

QLocale.Guatemala

QLocale.Guernsey

QLocale.Guinea

QLocale.GuineaBissau

QLocale.Guyana

QLocale.Haiti

QLocale.HeardAndMcDonaldIslands

QLocale.Honduras

QLocale.HongKong

QLocale.Hungary

QLocale.Iceland

QLocale.India

QLocale.Indonesia

QLocale.Iran

QLocale.Iraq

QLocale.Ireland

QLocale.IsleOfMan

QLocale.Israel

QLocale.Italy

QLocale.IvoryCoast

QLocale.Jamaica

QLocale.Japan

QLocale.Jersey

QLocale.Jordan

QLocale.Kazakhstan

QLocale.Kenya

QLocale.Kiribati

QLocale.Kosovo

Since Qt 5.2

QLocale.Kuwait

QLocale.Kyrgyzstan

QLocale.Laos

QLocale.LatinAmerica

QLocale.LatinAmericaAndTheCaribbean

Obsolete, use LatinAmerica instead

QLocale.Latvia

QLocale.Lebanon

QLocale.Lesotho

QLocale.Liberia

QLocale.Libya

QLocale.Liechtenstein

QLocale.Lithuania

QLocale.Luxembourg

QLocale.Macao

QLocale.Macau

QLocale.Macedonia

QLocale.Madagascar

QLocale.Malawi

QLocale.Malaysia

QLocale.Maldives

QLocale.Mali

QLocale.Malta

QLocale.MarshallIslands

QLocale.Martinique

QLocale.Mauritania

QLocale.Mauritius

QLocale.Mayotte

QLocale.Mexico

QLocale.Micronesia

QLocale.Moldova

QLocale.Monaco

QLocale.Mongolia

QLocale.Montenegro

QLocale.Montserrat

QLocale.Morocco

QLocale.Mozambique

QLocale.Myanmar

QLocale.Namibia

QLocale.NauruCountry

Osbolete alias for NauruTerritory

QLocale.NauruTerritory

Since 6.2

QLocale.Nepal

QLocale.Netherlands

QLocale.NewCaledonia

QLocale.NewZealand

QLocale.Nicaragua

QLocale.Niger

QLocale.Nigeria

QLocale.Niue

QLocale.NorfolkIsland

QLocale.NorthernMarianaIslands

QLocale.NorthKorea

QLocale.Norway

QLocale.Oman

QLocale.OutlyingOceania

Since Qt 5.7

QLocale.Pakistan

QLocale.Palau

QLocale.PalestinianTerritories

QLocale.Panama

QLocale.PapuaNewGuinea

QLocale.Paraguay

QLocale.PeoplesRepublicOfCongo

Obsolete, use CongoBrazzaville instead

QLocale.Peru

QLocale.Philippines

QLocale.Pitcairn

QLocale.Poland

QLocale.Portugal

QLocale.PuertoRico

QLocale.Qatar

QLocale.RepublicOfKorea

Obsolete, use SouthKorea instead

QLocale.Reunion

QLocale.Romania

QLocale.RussianFederation

QLocale.Russia

QLocale.Rwanda

QLocale.SaintBarthelemy

QLocale.SaintHelena

QLocale.SaintKittsAndNevis

QLocale.SaintLucia

QLocale.SaintMartin

QLocale.SaintPierreAndMiquelon

QLocale.SaintVincentAndGrenadines

QLocale.SaintVincentAndTheGrenadines

QLocale.Samoa

QLocale.SanMarino

QLocale.SaoTomeAndPrincipe

QLocale.SaudiArabia

QLocale.Senegal

QLocale.Serbia

QLocale.Seychelles

QLocale.SierraLeone

QLocale.Singapore

QLocale.SintMaarten

QLocale.Slovakia

QLocale.Slovenia

QLocale.SolomonIslands

QLocale.Somalia

QLocale.SouthAfrica

QLocale.SouthGeorgiaAndSouthSandwichIslands

QLocale.SouthGeorgiaAndTheSouthSandwichIslands

QLocale.SouthKorea

QLocale.SouthSudan

QLocale.Spain

QLocale.SriLanka

QLocale.Sudan

QLocale.Suriname

QLocale.SvalbardAndJanMayen

QLocale.SvalbardAndJanMayenIslands

QLocale.Swaziland

QLocale.Sweden

QLocale.Switzerland

QLocale.Syria

QLocale.SyrianArabRepublic

Obsolete, use Syria instead

QLocale.Taiwan

QLocale.Tajikistan

QLocale.Tanzania

QLocale.Thailand

QLocale.TimorLeste

QLocale.Togo

QLocale.TokelauCountry

Osbolete alias for TokelauTerritory

QLocale.TokelauTerritory

Since 6.2

QLocale.Tonga

QLocale.TrinidadAndTobago

QLocale.TristanDaCunha

QLocale.Tunisia

QLocale.Turkey

QLocale.Turkmenistan

QLocale.TurksAndCaicosIslands

QLocale.TuvaluCountry

Osbolete alias for TuvaluTerritory

QLocale.TuvaluTerritory

Since 6.2

QLocale.Uganda

QLocale.Ukraine

QLocale.UnitedArabEmirates

QLocale.UnitedKingdom

QLocale.UnitedStates

QLocale.UnitedStatesOutlyingIslands

QLocale.UnitedStatesMinorOutlyingIslands

QLocale.UnitedStatesVirginIslands

QLocale.Uruguay

QLocale.Uzbekistan

QLocale.Vanuatu

QLocale.VaticanCity

QLocale.VaticanCityState

QLocale.Venezuela

QLocale.Vietnam

QLocale.WallisAndFutuna

QLocale.WallisAndFutunaIslands

QLocale.WesternSahara

QLocale.World

Since Qt 5.12

QLocale.Yemen

QLocale.Zambia

QLocale.Zimbabwe

Note

Use the Territory alias for this enumeration where possible. The Country enum shall be renamed to Territory at a later release.

PySide6.QtCore.QLocale.MeasurementSystem#

This enum defines which units are used for measurement.

Constant

Description

QLocale.MetricSystem

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

QLocale.ImperialUSSystem

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

QLocale.ImperialUKSystem

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

QLocale.ImperialSystem

Provided for compatibility. Same as

PySide6.QtCore.QLocale.FormatType#

This enum describes the different formats that can be used when converting QDate , QTime , and QDateTime objects, as well as months and days, to strings specific to the locale.

Constant

Description

QLocale.LongFormat

Longer format.

QLocale.ShortFormat

Shorter format.

QLocale.NarrowFormat

A special version for use when space is very limited.

Note

NarrowFormat might contain the same text for different months and days. 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.

PySide6.QtCore.QLocale.NumberOption#

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

Description

QLocale.DefaultNumberOptions

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

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

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

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

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

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

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.

See also

setNumberOptions() numberOptions() FloatingPointPrecisionOption

PySide6.QtCore.QLocale.FloatingPointPrecisionOption#

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

Constant

Description

QLocale.FloatingPointShortest

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. In particular, trailing zeros are omitted (from the mantissa, in exponent formats).

See also

toString() number() number()

New in version 5.7.

PySide6.QtCore.QLocale.CurrencySymbolFormat#

Specifies the format of the currency symbol.

Constant

Description

QLocale.CurrencyIsoCode

a ISO-4217 code of the currency.

QLocale.CurrencySymbol

a currency symbol.

QLocale.CurrencyDisplayName

a user readable name of the currency.

New in version 4.8.

PySide6.QtCore.QLocale.DataSizeFormat#

Specifies the format for representation of data quantities.

Constant

Description

QLocale.DataSizeIecFormat

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

QLocale.DataSizeTraditionalFormat

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

QLocale.DataSizeSIFormat

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

New in version 5.10.

PySide6.QtCore.QLocale.LanguageCodeType#

This enum defines language code types that can be used to restrict set of language codes considered by codeToLanguage and languageToCode.

Constant

Description

QLocale.ISO639Part1

ISO 639 Part 1 Alpha 2 code.

QLocale.ISO639Part2B

ISO 639 Part 2 bibliographic Alpha 3 code.

QLocale.ISO639Part2T

ISO 639 Part 2 terminological Alpha 3 code.

QLocale.ISO639Part3

ISO 639 Part 3 Alpha 3 code.

QLocale.LegacyLanguageCode

Codes that are not part of the above set, but that were supported by Qt in the past. This value can only be used by codeToLanguage() . It is ignored when passed to languageToCode() .

QLocale.ISO639Part2

Any ISO 639 Part 2 code.

QLocale.ISO639Alpha2

Any ISO-639 2-letter code.

QLocale.ISO639Alpha3

Any ISO-639 3-letter code.

QLocale.ISO639

Any ISO 639 code.

QLocale.AnyLanguageCode

Specifies that any code can be used.

New in version 6.3.

PySide6.QtCore.QLocale.QuotationStyle#

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

Constant

Description

QLocale.StandardQuotation

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

QLocale.AlternateQuotation

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

See also

quoteString()

New in version 4.8.

PySide6.QtCore.QLocale.amText()#
Return type

str

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

See also

pmText()

PySide6.QtCore.QLocale.bcp47Name()#
Return type

str

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

static PySide6.QtCore.QLocale.c()#
Return type

PySide6.QtCore.QLocale

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

system()

static PySide6.QtCore.QLocale.codeToCountry(countryCode)#
Parameters

countryCodeQStringView

Return type

Country

Returns the QLocale::Territory enum corresponding to the two-letter or three-digit countryCode, as defined in the ISO 3166 standard.

If the code is invalid or not known AnyTerritory is returned.

Use codeToTerritory ( QStringView ) instead.

static PySide6.QtCore.QLocale.codeToLanguage(languageCode[, codeTypes=QLocale.LanguageCodeType.AnyLanguageCode])#
Parameters
  • languageCodeQStringView

  • codeTypesLanguageCodeTypes

Return type

Language

Returns the Language enum corresponding to the two- or three-letter languageCode, as defined in the ISO 639 standards.

If specified, codeTypes selects which set of codes to consider for conversion. By default all codes known to Qt are considered. The codes are matched in the following order: ISO639Part1, ISO639Part2B, ISO639Part2T, ISO639Part3, LegacyLanguageCode.

If the code is invalid or not known QLocale::AnyLanguage is returned.

static PySide6.QtCore.QLocale.codeToScript(scriptCode)#
Parameters

scriptCodeQStringView

Return type

Script

Returns the Script enum corresponding to the four-letter script scriptCode, as defined in the ISO 15924 standard.

If the code is invalid or not known AnyScript is returned.

static PySide6.QtCore.QLocale.codeToTerritory(territoryCode)#
Parameters

territoryCodeQStringView

Return type

Country

Returns the QLocale::Territory enum corresponding to the two-letter or three-digit territoryCode, as defined in the ISO 3166 standard.

If the code is invalid or not known AnyTerritory is returned.

PySide6.QtCore.QLocale.collation()#
Return type

PySide6.QtCore.QLocale

Returns the locale to use for collation.

The result is usually this locale; however, the system locale (which is commonly the default locale) will return the system collation locale. The result is suitable for passing to QCollator ‘s constructor.

See also

QCollator

static PySide6.QtCore.QLocale.countriesForLanguage(lang)#
Parameters

langLanguage

Return type

Use matchingLocales() instead and consult the territory() of each.

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.

PySide6.QtCore.QLocale.country()#
Return type

Country

Use territory() instead.

Returns the territory of this locale.

static PySide6.QtCore.QLocale.countryToCode(country)#
Parameters

countryCountry

Return type

str

Use territoryToCode() instead.

Returns the two-letter territory code for country, as defined in the ISO 3166 standard.

Note

For QLocale::AnyTerritory or QLocale::AnyCountry an empty string is returned.

static PySide6.QtCore.QLocale.countryToString(country)#
Parameters

countryCountry

Return type

str

Use territoryToString() instead.

Returns a QString containing the name of country.

PySide6.QtCore.QLocale.createSeparatedList(strl)#
Parameters

strl – list of strings

Return type

str

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

PySide6.QtCore.QLocale.currencySymbol([arg__1=QLocale.CurrencySymbolFormat.CurrencySymbol])#
Parameters

arg__1CurrencySymbolFormat

Return type

str

Returns a currency symbol according to the format.

PySide6.QtCore.QLocale.dateFormat([format=QLocale.FormatType.LongFormat])#
Parameters

formatFormatType

Return type

str

Returns the date format used for the current locale.

If format is LongFormat , the format will be elaborate, otherwise it will be short. For example, LongFormat for the en_US locale is dddd, MMMM d, yyyy, ShortFormat is M/d/yy.

PySide6.QtCore.QLocale.dateTimeFormat([format=QLocale.FormatType.LongFormat])#
Parameters

formatFormatType

Return type

str

Returns the date time format used for the current locale.

If format is LongFormat , the format will be elaborate, otherwise it will be short. For example, LongFormat for the en_US locale is dddd, MMMM d, yyyy h:mm:ss AP t, ShortFormat is M/d/yy h:mm AP.

PySide6.QtCore.QLocale.dayName(arg__1[, format=QLocale.FormatType.LongFormat])#
Parameters
Return type

str

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

For example, if the locale is en_US and day is 1, LongFormat will return Monday, ShortFormat Mon, and NarrowFormat M.

PySide6.QtCore.QLocale.decimalPoint()#
Return type

str

Returns the decimal point character of this locale.

PySide6.QtCore.QLocale.exponential()#
Return type

str

Returns the exponential character of this locale, used to separate exponent from mantissa in some floating-point numeric representations.

See also

toString(double, char, int)

PySide6.QtCore.QLocale.firstDayOfWeek()#
Return type

DayOfWeek

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

PySide6.QtCore.QLocale.formattedDataSize(bytes[, precision=2[, format=QLocale.DataSizeFormat.DataSizeIecFormat]])#
Parameters
  • bytes – int

  • precision – int

  • formatDataSizeFormats

Return type

str

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.

PySide6.QtCore.QLocale.groupSeparator()#
Return type

str

Returns the group separator character of this locale.

PySide6.QtCore.QLocale.language()#
Return type

Language

Returns the language of this locale.

static PySide6.QtCore.QLocale.languageToCode(language[, codeTypes=QLocale.LanguageCodeType.AnyLanguageCode])#
Parameters
  • languageLanguage

  • codeTypesLanguageCodeTypes

Return type

str

Returns the two- or three-letter language code for language, as defined in the ISO 639 standards.

If specified, codeTypes selects which set of codes to consider. The first code from the set that is defined for language is returned. Otherwise, all ISO-639 codes are considered. The codes are considered in the following order: ISO639Part1, ISO639Part2B, ISO639Part2T, ISO639Part3. LegacyLanguageCode is ignored by this function.

Note

For QLocale::C the function returns "C". For QLocale::AnyLanguage an empty string is returned. If the language has no code in any selected code set, an empty string is returned.

static PySide6.QtCore.QLocale.languageToString(language)#
Parameters

languageLanguage

Return type

str

Returns a QString containing the name of language.

static PySide6.QtCore.QLocale.matchingLocales(language, script, territory)#
Parameters
Return type

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

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

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

PySide6.QtCore.QLocale.measurementSystem()#
Return type

MeasurementSystem

Returns the measurement system for the locale.

PySide6.QtCore.QLocale.monthName(arg__1[, format=QLocale.FormatType.LongFormat])#
Parameters
Return type

str

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

For example, if the locale is en_US and month is 1, LongFormat will return January. ShortFormat Jan, and NarrowFormat J.

PySide6.QtCore.QLocale.name()#
Return type

str

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, will not contain it for compatibility reasons. Use bcp47Name() instead if you need a full locale name.

PySide6.QtCore.QLocale.nativeCountryName()#
Return type

str

Use nativeTerritoryName() instead.

Returns a native name of the territory for the locale. For example “España” for Spanish/Spain locale.

PySide6.QtCore.QLocale.nativeLanguageName()#
Return type

str

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

PySide6.QtCore.QLocale.nativeTerritoryName()#
Return type

str

Returns a native name of the territory for the locale. For example “España” for Spanish/Spain locale.

PySide6.QtCore.QLocale.negativeSign()#
Return type

str

Returns the negative sign character of this locale.

PySide6.QtCore.QLocale.numberOptions()#
Return type

NumberOptions

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

By default, no options are set for the standard locales, except for the “C” locale, which has OmitGroupSeparator set by default.

See also

setNumberOptions() toString() groupSeparator() FloatingPointPrecisionOption

PySide6.QtCore.QLocale.__ne__(rhs)#
Parameters

rhsPySide6.QtCore.QLocale

Return type

bool

Returns true if the two QLocale objects, lhs and rhs, differ; otherwise returns false.

Note

The system locale is not equal to the QLocale object constructed from its language() , script() and territory() , even if the two agree in all data fields. Nor are two locales with different number options equal.

See also

operator==() setNumberOptions()

PySide6.QtCore.QLocale.__eq__(rhs)#
Parameters

rhsPySide6.QtCore.QLocale

Return type

bool

Returns true if the two QLocale objects, lhs and rhs, are the same; otherwise returns false.

Note

The system locale is not equal to the QLocale object constructed from its language() , script() and territory() , even if the two agree in all data fields. Nor are two locales with different number options equal.

See also

operator!=() setNumberOptions()

PySide6.QtCore.QLocale.percent()#
Return type

str

Returns the percent character of this locale.

See also

toString()

PySide6.QtCore.QLocale.pmText()#
Return type

str

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

See also

amText()

PySide6.QtCore.QLocale.positiveSign()#
Return type

str

Returns the positive sign character of this locale.

PySide6.QtCore.QLocale.quoteString(str[, style=QLocale.QuotationStyle.StandardQuotation])#
Parameters
Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.quoteString(str[, style=QLocale.QuotationStyle.StandardQuotation])
Parameters
Return type

str

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

PySide6.QtCore.QLocale.script()#
Return type

Script

Returns the script of this locale.

static PySide6.QtCore.QLocale.scriptToCode(script)#
Parameters

scriptScript

Return type

str

Returns the four-letter script code for script, as defined in the ISO 15924 standard.

Note

For QLocale::AnyScript an empty string is returned.

static PySide6.QtCore.QLocale.scriptToString(script)#
Parameters

scriptScript

Return type

str

Returns a QString containing the name of script.

static PySide6.QtCore.QLocale.setDefault(locale)#
Parameters

localePySide6.QtCore.QLocale

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.

See also

system() c()

PySide6.QtCore.QLocale.setNumberOptions(options)#
Parameters

optionsNumberOptions

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

See also

numberOptions() FloatingPointPrecisionOption

PySide6.QtCore.QLocale.standaloneDayName(arg__1[, format=QLocale.FormatType.LongFormat])#
Parameters
Return type

str

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

PySide6.QtCore.QLocale.standaloneMonthName(arg__1[, format=QLocale.FormatType.LongFormat])#
Parameters
Return type

str

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

PySide6.QtCore.QLocale.swap(other)#
Parameters

otherPySide6.QtCore.QLocale

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

static PySide6.QtCore.QLocale.system()#
Return type

PySide6.QtCore.QLocale

Returns a QLocale object initialized to the system locale.

The system locale may use system-specific sources for locale data, where available, otherwise falling back on QLocale ‘s built-in database entry for the language, script and territory the system reports.

For example, 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()

PySide6.QtCore.QLocale.territory()#
Return type

Country

Returns the territory of this locale.

static PySide6.QtCore.QLocale.territoryToCode(territory)#
Parameters

territoryCountry

Return type

str

Returns the two-letter territory code for territory, as defined in the ISO 3166 standard.

Note

For QLocale::AnyTerritory an empty string is returned.

static PySide6.QtCore.QLocale.territoryToString(territory)#
Parameters

territoryCountry

Return type

str

Returns a QString containing the name of territory.

PySide6.QtCore.QLocale.textDirection()#
Return type

LayoutDirection

Returns the text direction of the language.

PySide6.QtCore.QLocale.timeFormat([format=QLocale.FormatType.LongFormat])#
Parameters

formatFormatType

Return type

str

Returns the time format used for the current locale.

If format is LongFormat , the format will be elaborate, otherwise it will be short. For example, LongFormat for the en_US locale is h:mm:ss AP t, ShortFormat is h:mm AP.

PySide6.QtCore.QLocale.toCurrencyString(arg__1[, symbol=""[, precision=-1]])#
Parameters
  • arg__1double

  • symbol – str

  • precision – int

Return type

str

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.

See also

currencySymbol()

PySide6.QtCore.QLocale.toCurrencyString(i[, symbol=""])
Parameters
  • iushort

  • symbol – str

Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toCurrencyString(i[, symbol=""])
Parameters
  • iuint

  • symbol – str

Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toCurrencyString(i[, symbol=""])
Parameters
  • ishort

  • symbol – str

Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toCurrencyString(arg__1[, symbol=""])
Parameters
  • arg__1qlonglong

  • symbol – str

Return type

str

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

PySide6.QtCore.QLocale.toCurrencyString(arg__1[, symbol=""])
Parameters
  • arg__1qulonglong

  • symbol – str

Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toCurrencyString(i[, symbol=""[, precision=-1]])
Parameters
  • i – float

  • symbol – str

  • precision – int

Return type

str

This function overloads toCurrencyString() .

PySide6.QtCore.QLocale.toCurrencyString(i[, symbol=""])
Parameters
  • i – int

  • symbol – str

Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toDate(string[, format=QLocale.FormatType.LongFormat])#
Parameters
Return type

PySide6.QtCore.QDate

Reads string as a date in a locale-specific format.

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

Note

Month and day names, where used, must be given in the locale’s language.

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

PySide6.QtCore.QLocale.toDate(string, format, cal)
Parameters
Return type

PySide6.QtCore.QDate

This is an overloaded function.

PySide6.QtCore.QLocale.toDate(string, format)
Parameters
  • string – str

  • format – str

Return type

PySide6.QtCore.QDate

Reads string as a date in the given format.

Parses string and returns the date it represents. See fromString() for the interpretation of format.

Note

Month and day names, where used, must be given in the locale’s language.

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

PySide6.QtCore.QLocale.toDate(string, format, cal)
Parameters
Return type

PySide6.QtCore.QDate

This is an overloaded function.

PySide6.QtCore.QLocale.toDateTime(string[, format=QLocale.FormatType.LongFormat])#
Parameters
Return type

PySide6.QtCore.QDateTime

Reads string as a date-time in a locale-specific format.

Parses string and returns the date-time it represents. The format of the date string is chosen according to the format parameter (see dateFormat() ).

Note

Month and day names, where used, must be given in the locale’s language. Any am/pm indicators used must match amText() or pmText() , ignoring case.

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

PySide6.QtCore.QLocale.toDateTime(string, format, cal)
Parameters
Return type

PySide6.QtCore.QDateTime

This is an overloaded function.

PySide6.QtCore.QLocale.toDateTime(string, format)
Parameters
  • string – str

  • format – str

Return type

PySide6.QtCore.QDateTime

Reads string as a date-time in the given format.

Parses string and returns the date-time it represents. See fromString() for the interpretation of format.

Note

Month and day names, where used, must be given in the locale’s language. Any am/pm indicators used must match amText() or pmText() , ignoring case.

If the string could not be parsed, returns an invalid QDateTime . If the string can be parsed and represents an invalid date-time (e.g. in a gap skipped by a time-zone transition), an invalid QDateTime is returned, whose toMSecsSinceEpoch() represents a near-by date-time that is valid. Passing that to fromMSecsSinceEpoch() will produce a valid date-time that isn’t faithfully represented by the string parsed.

PySide6.QtCore.QLocale.toDateTime(string, format, cal)
Parameters
Return type

PySide6.QtCore.QDateTime

This is an overloaded function.

PySide6.QtCore.QLocale.toDouble(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

double

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 None, failure is reported by setting *``ok`` to false, and success by setting *``ok`` to true.

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

ok = bool()
d = float()
c = QLocale(QLocale.C)
d = c.toDouble(u"1234.56", ok) # ok == true, d == 1234.56
d = c.toDouble(u"1,234.56", ok) # ok == true, d == 1234.56
d = c.toDouble(u"1234,56", ok) # ok == false, d == 0
german = QLocale(QLocale.German)
d = german.toDouble(u"1234,56", ok) # ok == true, d == 1234.56
d = german.toDouble(u"1.234,56", ok) # ok == true, d == 1234.56
d = german.toDouble(u"1234.56", ok) # ok == false, d == 0
d = german.toDouble(u"1.234", ok) # ok == true, d == 1234.0

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toDouble(s)
Parameters

s – str

Return type

(float, bool ok)

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 None, 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.

ok = bool()
d = float()
c = QLocale(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, d == 0
german = QLocale(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 == 0
d = german.toDouble("1.234", ok) # ok == true, d == 1234.0

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toFloat(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

float

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 None, failure is reported by setting *``ok`` to false, and success by setting *``ok`` to true.

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toFloat(s)
Parameters

s – str

Return type

(float, bool ok)

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 None, 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.

PySide6.QtCore.QLocale.toInt(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

int

Returns the int represented by the localized string s.

If the conversion fails, the function returns 0.

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

This function ignores leading and trailing whitespace.

See also

toUInt() toString()

PySide6.QtCore.QLocale.toInt(s)
Parameters

s – str

Return type

(int, bool ok)

Returns the int represented by the localized string s.

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

See also

toUInt() toString()

PySide6.QtCore.QLocale.toLong(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

long

Returns the long int represented by the localized string s.

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toLong(s[, ok=None])
Parameters
  • s – str

  • ok – bool

Return type

long

Returns the long int represented by the localized string s.

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toLongLong(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

qlonglong

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

If the conversion fails, the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toLongLong(s)
Parameters

s – str

Return type

(int, bool ok)

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

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toLower(str)#
Parameters

str – str

Return type

str

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 toLower() as a generic fallback.

See also

toLower()

PySide6.QtCore.QLocale.toShort(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

short

Returns the short int represented by the localized string s.

If the conversion fails, the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toShort(s)
Parameters

s – str

Return type

(int, bool ok)

Returns the short int represented by the localized string s.

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toString(dateTime, format)#
Parameters
Return type

str

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.

PySide6.QtCore.QLocale.toString(f[, format='g'[, precision=6]])
Parameters
  • fdouble

  • formatchar

  • precision – int

Return type

str

This is an overloaded function.

Returns a string representing the floating-point number f.

The form of the representation is controlled by the format and precision parameters.

The format defaults to 'g'. It can be any of the following:

Format

Meaning

'e'

format as [-]9.9e[+|-]999

'E'

format as [-]9.9E[+|-]999

'f'

format as [-]9.9

'g'

use 'e' or 'f' format, whichever is more concise

'G'

use 'E' or 'f' format, whichever is more concise

For the 'e', 'E', and 'f' formats, the precision represents the number of digits after the decimal point. For the 'g' and 'G' formats, the precision represents the maximum number of significant digits (trailing zeroes are omitted). The special precision value FloatingPointShortest selects the shortest representation that, when read as a number, gets back the original floating-point value. Aside from that, any negative precision is ignored in favor of the default, 6.

For the 'e', 'f' and 'g' formats, positive infinity is represented as “inf”, negative infinity as “-inf” and floating-point NaN (not-a-number) values are represented as “nan”. For the 'E' and 'G' formats, “INF” and “NAN” are used instead. This does not vary with locale.

PySide6.QtCore.QLocale.toString(f[, format='g'[, precision=6]])
Parameters
  • f – float

  • formatchar

  • precision – int

Return type

str

This is an overloaded function.

Returns a string representing the floating-point number f.

The format and precision have the same meanings as described in toString(double, char, int) .

PySide6.QtCore.QLocale.toString(i)
Parameters

i – int

Return type

str

This is an overloaded function.

See also

toInt()

PySide6.QtCore.QLocale.toString(i)
Parameters

ilong

Return type

str

This is an overloaded function.

See also

toLong()

PySide6.QtCore.QLocale.toString(time, format)
Parameters
Return type

str

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

toString()

PySide6.QtCore.QLocale.toString(i)
Parameters

iqlonglong

Return type

str

Returns a localized string representation of i.

PySide6.QtCore.QLocale.toString(i)
Parameters

ishort

Return type

str

This is an overloaded function.

See also

toShort()

PySide6.QtCore.QLocale.toString(i)
Parameters

iulong

Return type

str

This is an overloaded function.

See also

toULong()

PySide6.QtCore.QLocale.toString(dateTime, format)
Parameters
Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toString(dateTime, format, cal)
Parameters
Return type

str

Returns a localized string representation of the given dateTime according to the specified format (see dateTimeFormat() ), optionally for a specified calendar cal.

Note

Some locales may use formats that limit the range of years they can represent.

PySide6.QtCore.QLocale.toString(dateTime[, format=QLocale.FormatType.LongFormat])
Parameters
Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toString(time, format)
Parameters
Return type

str

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

toString()

PySide6.QtCore.QLocale.toString(time[, format=QLocale.FormatType.LongFormat])
Parameters
Return type

str

Returns a localized string representation of the given time in the specified format (see timeFormat() ).

PySide6.QtCore.QLocale.toString(date, format)
Parameters
Return type

str

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

toString()

PySide6.QtCore.QLocale.toString(date, format, cal)
Parameters
Return type

str

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

See also

toString()

PySide6.QtCore.QLocale.toString(date, format)
Parameters
Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toString(date, format, cal)
Parameters
Return type

str

Returns a localized string representation of the given date according to the specified format (see dateFormat() ), optionally for a specified calendar cal.

Note

Some locales may use formats that limit the range of years they can represent.

PySide6.QtCore.QLocale.toString(date[, format=QLocale.FormatType.LongFormat])
Parameters
Return type

str

This is an overloaded function.

PySide6.QtCore.QLocale.toString(dateTime, format, cal)
Parameters
Return type

str

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

PySide6.QtCore.QLocale.toTime(string, format)#
Parameters
  • string – str

  • format – str

Return type

PySide6.QtCore.QTime

Reads string as a time in the given format.

Parses string and returns the time it represents. See fromString() for the interpretation of format.

Note

Any am/pm indicators used must match amText() or pmText() , ignoring case.

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

PySide6.QtCore.QLocale.toTime(string[, format=QLocale.FormatType.LongFormat])
Parameters
Return type

PySide6.QtCore.QTime

Reads string as a time in a locale-specific format.

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

Note

Any am/pm indicators used must match amText() or pmText() , ignoring case.

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

PySide6.QtCore.QLocale.toUInt(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

uint

Returns the unsigned int represented by the localized string s.

If the conversion fails, the function returns 0.

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

This function ignores leading and trailing whitespace.

See also

toInt() toString()

PySide6.QtCore.QLocale.toUInt(s)
Parameters

s – str

Return type

(int, bool ok)

Returns the unsigned int represented by the localized string s.

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

See also

toInt() toString()

PySide6.QtCore.QLocale.toULong(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

ulong

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

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toULong(s[, ok=None])
Parameters
  • s – str

  • ok – bool

Return type

ulong

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

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toULongLong(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

qulonglong

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

If the conversion fails, the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toULongLong(s)
Parameters

s – str

Return type

(int, bool ok)

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

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toUShort(s[, ok=None])#
Parameters
  • sQStringView

  • ok – bool

Return type

ushort

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

If the conversion fails, the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toUShort(s)
Parameters

s – str

Return type

(int, bool ok)

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

If the conversion fails the function returns 0.

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

This function ignores leading and trailing whitespace.

PySide6.QtCore.QLocale.toUpper(str)#
Parameters

str – str

Return type

str

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 toUpper() as a generic fallback.

See also

toUpper()

PySide6.QtCore.QLocale.uiLanguages()#
Return type

list of strings

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 load() function.

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

PySide6.QtCore.QLocale.weekdays()#
Return type

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

PySide6.QtCore.QLocale.zeroDigit()#
Return type

str

Returns the zero digit character of this locale.

See also

toString()