Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <qlocale.h>
Public Member Functions | |
QLocale () | |
Constructs a QLocale object initialized with the default locale. | |
QLocale (const QString &name) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QLocale (QStringView name) | |
\variable QLocale::DefaultTwoDigitBaseYear | |
QLocale (Language language, Territory territory) | |
Constructs a QLocale object for the specified language and territory. | |
QLocale (Language language, Script script=AnyScript, Territory territory=AnyTerritory) | |
QLocale (const QLocale &other) noexcept | |
Constructs a QLocale object as a copy of other. | |
QLocale & | operator= (const QLocale &other) noexcept |
Assigns other to this QLocale object and returns a reference to this QLocale object. | |
~QLocale () | |
Destructor. | |
void | swap (QLocale &other) noexcept |
Language | language () const |
Returns the language of this locale. | |
Script | script () const |
Territory | territory () const |
QString | name (TagSeparator separator=TagSeparator::Underscore) const |
The short name of this locale. | |
QString | bcp47Name (TagSeparator separator=TagSeparator::Dash) const |
Returns the BCP47 field names joined with dashes. | |
QString | nativeLanguageName () const |
QString | nativeTerritoryName () const |
short | toShort (const QString &s, bool *ok=nullptr) const |
Returns the short int represented by the localized string s. | |
ushort | toUShort (const QString &s, bool *ok=nullptr) const |
Returns the unsigned short int represented by the localized string s. | |
int | toInt (const QString &s, bool *ok=nullptr) const |
Returns the int represented by the localized string s. | |
uint | toUInt (const QString &s, bool *ok=nullptr) const |
Returns the unsigned int represented by the localized string s. | |
long | toLong (const QString &s, bool *ok=nullptr) const |
ulong | toULong (const QString &s, bool *ok=nullptr) const |
qlonglong | toLongLong (const QString &s, bool *ok=nullptr) const |
Returns the long long int represented by the localized string s. | |
qulonglong | toULongLong (const QString &s, bool *ok=nullptr) const |
Returns the unsigned long long int represented by the localized string s. | |
float | toFloat (const QString &s, bool *ok=nullptr) const |
Returns the float represented by the localized string s. | |
double | toDouble (const QString &s, bool *ok=nullptr) const |
Returns the double represented by the localized string s. | |
short | toShort (QStringView s, bool *ok=nullptr) const |
Returns the short int represented by the localized string s. | |
ushort | toUShort (QStringView s, bool *ok=nullptr) const |
Returns the unsigned short int represented by the localized string s. | |
int | toInt (QStringView s, bool *ok=nullptr) const |
Returns the int represented by the localized string s. | |
uint | toUInt (QStringView s, bool *ok=nullptr) const |
Returns the unsigned int represented by the localized string s. | |
long | toLong (QStringView s, bool *ok=nullptr) const |
ulong | toULong (QStringView s, bool *ok=nullptr) const |
qlonglong | toLongLong (QStringView s, bool *ok=nullptr) const |
Returns the long long int represented by the localized string s. | |
qulonglong | toULongLong (QStringView s, bool *ok=nullptr) const |
Returns the unsigned long long int represented by the localized string s. | |
float | toFloat (QStringView s, bool *ok=nullptr) const |
Returns the float represented by the localized string s. | |
double | toDouble (QStringView s, bool *ok=nullptr) const |
Returns the double represented by the localized string s. | |
QString | toString (qlonglong i) const |
Returns a localized string representation of i. | |
QString | toString (qulonglong i) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QString | toString (long i) const |
QString | toString (ulong i) const |
QString | toString (short i) const |
QString | toString (ushort i) const |
QString | toString (int i) const |
QString | toString (uint i) const |
QString | toString (double f, char format='g', int precision=6) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns a string representing the floating-point number f. | |
QString | toString (float f, char format='g', int precision=6) const |
QString | toString (QDate date, const QString &format) const |
Returns a localized string representation of the given date in the specified format. | |
QString | toString (QTime time, const QString &format) const |
Returns a localized string representation of the given time according to the specified format. | |
QString | toString (const QDateTime &dateTime, const QString &format) const |
QString | toString (QDate date, QStringView format) const |
QString | toString (QTime time, QStringView format) const |
QString | toString (const QDateTime &dateTime, QStringView format) const |
QString | toString (QDate date, FormatType format=LongFormat) const |
QString | toString (QTime time, FormatType format=LongFormat) const |
Returns a localized string representation of the given time in the specified format (see timeFormat()). | |
QString | toString (const QDateTime &dateTime, FormatType format=LongFormat) const |
QString | toString (QDate date, QStringView format, QCalendar cal) const |
QString | toString (QDate date, FormatType format, QCalendar cal) const |
QString | toString (const QDateTime &dateTime, FormatType format, QCalendar cal) const |
QString | toString (const QDateTime &dateTime, QStringView format, QCalendar cal) const |
QString | dateFormat (FormatType format=LongFormat) const |
QString | timeFormat (FormatType format=LongFormat) const |
QString | dateTimeFormat (FormatType format=LongFormat) const |
QString | decimalPoint () const |
QString | groupSeparator () const |
QString | percent () const |
QString | zeroDigit () const |
QString | negativeSign () const |
QString | positiveSign () const |
QString | exponential () const |
QString | monthName (int, FormatType format=LongFormat) const |
QString | standaloneMonthName (int, FormatType format=LongFormat) const |
QString | dayName (int, FormatType format=LongFormat) const |
QString | standaloneDayName (int, FormatType format=LongFormat) const |
Qt::DayOfWeek | firstDayOfWeek () const |
QList< Qt::DayOfWeek > | weekdays () const |
QString | amText () const |
QString | pmText () const |
MeasurementSystem | measurementSystem () const |
QLocale | collation () const |
Qt::LayoutDirection | textDirection () const |
QString | toUpper (const QString &str) const |
QString | toLower (const QString &str) const |
QString | currencySymbol (CurrencySymbolFormat=CurrencySymbol) const |
QString | toCurrencyString (qlonglong, const QString &symbol=QString()) const |
QString | toCurrencyString (qulonglong, const QString &symbol=QString()) const |
QString | toCurrencyString (short i, const QString &symbol=QString()) const |
QString | toCurrencyString (ushort i, const QString &symbol=QString()) const |
QString | toCurrencyString (int i, const QString &symbol=QString()) const |
QString | toCurrencyString (uint i, const QString &symbol=QString()) const |
QString | toCurrencyString (double, const QString &symbol=QString(), int precision=-1) const |
QString | toCurrencyString (float i, const QString &symbol=QString(), int precision=-1) const |
QString | formattedDataSize (qint64 bytes, int precision=2, DataSizeFormats format=DataSizeIecFormat) const |
QStringList | uiLanguages (TagSeparator separator=TagSeparator::Dash) const |
List of locale names for use in selecting translations. | |
void | setNumberOptions (NumberOptions options) |
NumberOptions | numberOptions () const |
QString | quoteString (const QString &str, QuotationStyle style=StandardQuotation) const |
QString | quoteString (QStringView str, QuotationStyle style=StandardQuotation) const |
QString | createSeparatedList (const QStringList &strl) const |
Static Public Member Functions | |
static QString | languageToCode (Language language, LanguageCodeTypes codeTypes=AnyLanguageCode) |
Returns the two- or three-letter language code for language, as defined in the ISO 639 standards. | |
static Language | codeToLanguage (QStringView languageCode, LanguageCodeTypes codeTypes=AnyLanguageCode) noexcept |
Returns the QLocale::Language enum corresponding to the two- or three-letter languageCode, as defined in the ISO 639 standards. | |
static QString | territoryToCode (Territory territory) |
static Territory | codeToTerritory (QStringView territoryCode) noexcept |
static QString | scriptToCode (Script script) |
Returns the four-letter script code for script, as defined in the ISO 15924 standard. | |
static Script | codeToScript (QStringView scriptCode) noexcept |
Returns the QLocale::Script enum corresponding to the four-letter script scriptCode, as defined in the ISO 15924 standard. | |
static QString | languageToString (Language language) |
Returns a QString containing the name of language. | |
static QString | territoryToString (Territory territory) |
static QString | scriptToString (Script script) |
static void | setDefault (const QLocale &locale) |
\nonreentrant | |
static QLocale | c () |
Returns a QLocale object initialized to the "C" locale. | |
static QLocale | system () |
Returns a QLocale object initialized to the system locale. | |
static QList< QLocale > | matchingLocales (QLocale::Language language, QLocale::Script script, QLocale::Territory territory) |
Returns a list of valid locale objects that match the given language, script and territory. | |
Static Public Attributes | |
static constexpr int | DefaultTwoDigitBaseYear = 1900 |
Friends | |
class | QString |
class | QByteArray |
class | QIntValidator |
class | QDoubleValidatorPrivate |
class | QTextStream |
class | QTextStreamPrivate |
class | QLocalePrivate |
class | QSystemLocale |
class | QTimeZonePrivate |
class | QCalendarBackend |
class | QRomanCalendar |
Q_CORE_EXPORT size_t | qHash (const QLocale &key, size_t seed=0) |
bool | comparesEqual (const QLocale &lhs, const QLocale &rhs) noexcept |
Q_CORE_EXPORT bool | comparesEqual (const QLocale &lhs, QLocale::Language lang) |
using QLocale::Territory = Country |
enum QLocale::Country : ushort |
Specifies the format for representation of data quantities.
\omitvalue DataSizeBase1000 \omitvalue DataSizeSIQuantifiers \value DataSizeIecFormat format using base 1024 and IEC prefixes: KiB, MiB, GiB, ... \value DataSizeTraditionalFormat format using base 1024 and SI prefixes: kB, MB, GB, ... \value DataSizeSIFormat format using base 1000 and SI prefixes: kB, MB, GB, ...
Enumerator | |
---|---|
DataSizeBase1000 | |
DataSizeSIQuantifiers | |
DataSizeIecFormat | |
DataSizeTraditionalFormat | |
DataSizeSIFormat |
enum QLocale::FormatType |
enum QLocale::Language : ushort |
enum QLocale::Script : ushort |
|
strong |
Indicate how to combine the parts that make up a locale identifier.
A locale identifier may be made up of several tags, indicating language, script and territory (plus, potentially, other details), joined together to form the identifier. Various standards and conventional forms use either a dash (the Unicode HYPHEN-MINUS, U+002D) or an underscore (LOW LINE, U+005F). Different clients of QLocale may thus need one or the other.
\value Dash Use {'-'}, the dash or hyphen character. \value Underscore Use
{'_'}, the underscore character.
Enumerator | |
---|---|
Dash | |
Underscore |
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().
Definition at line 1172 of file qlocale.cpp.
|
explicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
explicit |
\variable QLocale::DefaultTwoDigitBaseYear
The default start year of the century within which a format taking a two-digit year will select. The value of the constant is {1900}
.
Some locales use, particularly for ShortFormat, only the last two digits of the year. Proir to 6.7 the year 1900 was always used as a base year for such cases. Now various QLocale and QDate functions have the overloads that allow callers to specify the base year, and this constant is used as its default value.
Constructs a QLocale object with the specified name.
The name has the format "language[_script][_territory][.codeset][@modifier]" or "C", where:
\list
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).
Definition at line 1153 of file qlocale.cpp.
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.
Definition at line 1191 of file qlocale.cpp.
QLocale::QLocale | ( | Language | language, |
Script | script = AnyScript, | ||
Territory | territory = AnyTerritory ) |
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
\list
AnyLanguage
and no language can be inferred from script and territory Definition at line 1215 of file qlocale.cpp.
|
defaultnoexcept |
Constructs a QLocale object as a copy of other.
QLocale::~QLocale | ( | ) |
Destructor.
Definition at line 1230 of file qlocale.cpp.
QString QLocale::amText | ( | ) | const |
Returns the localized name of the "AM" suffix for times specified using the conventions of the 12-hour clock.
Definition at line 3574 of file qlocale.cpp.
QString QLocale::bcp47Name | ( | TagSeparator | separator = TagSeparator::Dash | ) | const |
Returns the BCP47 field names joined with dashes.
This combines as many of language, script and territory (and possibly other BCP47 fields) for this locale as are needed to uniquely specify it. Note that fields may be omitted if the Unicode consortium's \l {Matching combinations of language, script and territory}{Likely Subtag Rules} imply the omitted fields when given those retained. See \l name() for how to construct a string from individual fields, if some other format is needed.
Unlike uiLanguages(), the value returned by bcp47Name() represents the locale name of the QLocale data; this need not be the language the user-interface should be in.
This function tries to conform the locale name to the IETF Best Common Practice 47, defined by RFC 5646. Since Qt 6.7, it supports an optional separator parameter which can be used to override the BCP47-specified use of a hyphen to separate the tags. For use in IETF-defined protocols, however, the default, QLocale::TagSeparator::Dash, should be retained.
Definition at line 1580 of file qlocale.cpp.
|
inlinestatic |
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).
|
staticnoexcept |
Returns the QLocale::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.
Definition at line 1628 of file qlocale.cpp.
|
staticnoexcept |
Returns the QLocale::Script enum corresponding to the four-letter script scriptCode, as defined in the ISO 15924 standard.
If the code is invalid or not known QLocale::AnyScript is returned.
Definition at line 1719 of file qlocale.cpp.
|
staticnoexcept |
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 QLocale::AnyTerritory is returned.
Definition at line 1659 of file qlocale.cpp.
QLocale QLocale::collation | ( | ) | const |
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.
Definition at line 5135 of file qlocale.cpp.
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.
Definition at line 1344 of file qlocale.cpp.
QString QLocale::currencySymbol | ( | CurrencySymbolFormat | format = CurrencySymbol | ) | const |
Definition at line 4738 of file qlocale.cpp.
QString QLocale::dateFormat | ( | FormatType | format = LongFormat | ) | const |
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}.
Definition at line 2432 of file qlocale.cpp.
QString QLocale::dateTimeFormat | ( | FormatType | format = LongFormat | ) | const |
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}.
Definition at line 2494 of file qlocale.cpp.
QString QLocale::dayName | ( | int | day, |
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.
For example, if the locale is en_US
and day is 1, \l LongFormat will return Monday
, \l ShortFormat Mon
, and \l NarrowFormat M
.
Definition at line 3095 of file qlocale.cpp.
QString QLocale::decimalPoint | ( | ) | const |
Returns the fractional part separator for this locale.
This is the token that separates the whole number part from the fracional part in the representation of a number which has a fractional part. This is commonly called the "decimal point character" - even though, in many locales, it is not a "point" (or similar dot). It is (since Qt 6.0) returned as a string in case some locale needs more than one UTF-16 code-point to represent its separator.
Definition at line 2753 of file qlocale.cpp.
QString QLocale::exponential | ( | ) | const |
Returns the exponent separator for this locale.
This is a token used to separate mantissa from exponent in some floating-point numeric representations. It is (since Qt 6.0) returned as a string because, in some locales, it is not a single character - for example, it may consist of a multiplication sign and a representation of the "ten to the power" operator.
Definition at line 2860 of file qlocale.cpp.
Qt::DayOfWeek QLocale::firstDayOfWeek | ( | ) | const |
Returns the first day of the week according to the current locale.
Definition at line 3384 of file qlocale.cpp.
QString QLocale::formattedDataSize | ( | qint64 | bytes, |
int | precision = 2, | ||
DataSizeFormats | format = DataSizeIecFormat ) const |
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 \l DataSizeIecFormat (the default), this function returns "16.00 KiB"; for 1330409069609 bytes it returns "1.21 GiB"; and so on. If format is \l DataSizeIecFormat or \l DataSizeTraditionalFormat, the given number of bytes is divided by a power of 1024, with result less than 1024; for \l 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.
Definition at line 4885 of file qlocale.cpp.
QString QLocale::groupSeparator | ( | ) | const |
Returns the digit-grouping separator for this locale.
This is a token used to break up long sequences of digits, in the representation of a number, to make it easier to read. In some locales it may be empty, indicating that digits should not be broken up into groups in this way. In others it may be a spacing character. It is (since Qt 6.0) returned as a string in case some locale needs more than one UTF-16 code-point to represent its separator.
Definition at line 2772 of file qlocale.cpp.
QLocale::Language QLocale::language | ( | ) | const |
Returns the language of this locale.
Definition at line 1415 of file qlocale.cpp.
|
static |
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.
{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.Definition at line 1608 of file qlocale.cpp.
Returns a QString containing the name of language.
Definition at line 1730 of file qlocale.cpp.
|
static |
Returns a list of valid locale objects that match the given language, script and territory.
Getting a list of all locales: QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyTerritory);
Getting a list of locales suitable for Russia: QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::Russia);
Definition at line 2991 of file qlocale.cpp.
QLocale::MeasurementSystem QLocale::measurementSystem | ( | ) | const |
Returns the measurement system for the locale.
Definition at line 3458 of file qlocale.cpp.
QString QLocale::monthName | ( | int | month, |
FormatType | type = LongFormat ) const |
Returns the localized name of month, in the format specified by type.
For example, if the locale is en_US
and month is 1, \l LongFormat will return January
. \l ShortFormat Jan
, and \l NarrowFormat J
.
Definition at line 3061 of file qlocale.cpp.
QString QLocale::name | ( | TagSeparator | separator = TagSeparator::Underscore | ) | const |
The short name of this locale.
Returns the language and territory of this locale as a string of the form "language_territory", where language is a lowercase, two-letter ISO 639 language code, and territory is an uppercase, two- or three-letter ISO 3166 territory code. If the locale has no specified territory, only the language name is returned. Since Qt 6.7 an optional separator parameter can be supplied to override the default underscore character separating the two tags.
Even if the QLocale object was constructed with an explicit script, name() will not contain it for compatibility reasons. Use \l bcp47Name() instead if you need a full locale name, or construct the string you want to identify a locale by from those returned by passing its \l language() to \l languageToCode() and similar for the script and territory.
Definition at line 1510 of file qlocale.cpp.
Referenced by testing.tools.encode_pdf_filter._PdfStream::RegisterByName().
QString QLocale::nativeLanguageName | ( | ) | const |
Returns a native name of the language for the locale. For example "Schweizer Hochdeutsch" for the Swiss-German locale.
Definition at line 5155 of file qlocale.cpp.
QString QLocale::nativeTerritoryName | ( | ) | const |
Returns a native name of the territory for the locale. For example "España" for Spanish/Spain locale.
Definition at line 5175 of file qlocale.cpp.
QString QLocale::negativeSign | ( | ) | const |
Returns the negative sign indicator of this locale.
This is a token presumed to be used as a prefix to a number to indicate that it is negative. It is (since Qt 6.0) returned as a string because, in some locales, it is not a single character - for example, because it includes a text-direction-control character.
Definition at line 2825 of file qlocale.cpp.
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, except for the "C" locale, which has OmitGroupSeparator set by default.
Definition at line 1291 of file qlocale.cpp.
QString QLocale::percent | ( | ) | const |
Returns the percent marker of this locale.
This is a token presumed to be appended to a number to indicate a percentage. It is (since Qt 6.0) returned as a string because, in some locales, it is not a single character - for example, because it includes a text-direction-control character.
Definition at line 2789 of file qlocale.cpp.
QString QLocale::pmText | ( | ) | const |
Returns the localized name of the "PM" suffix for times specified using the conventions of the 12-hour clock.
Definition at line 3594 of file qlocale.cpp.
QString QLocale::positiveSign | ( | ) | const |
Returns the positive sign indicator of this locale.
This is a token presumed to be used as a prefix to a number to indicate that it is positive. It is (since Qt 6.0) returned as a string because, in some locales, it is not a single character - for example, because it includes a text-direction-control character.
Definition at line 2842 of file qlocale.cpp.
|
inline |
QString QLocale::quoteString | ( | QStringView | str, |
QuotationStyle | style = StandardQuotation ) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1310 of file qlocale.cpp.
QLocale::Script QLocale::script | ( | ) | const |
Returns the script of this locale.
Definition at line 1427 of file qlocale.cpp.
Returns the four-letter script code for script, as defined in the ISO 15924 standard.
{QLocale::AnyScript} an empty string is returned.Definition at line 1705 of file qlocale.cpp.
Returns a QString containing the name of script.
Definition at line 1772 of file qlocale.cpp.
\nonreentrant
Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.
Definition at line 1393 of file qlocale.cpp.
void QLocale::setNumberOptions | ( | NumberOptions | options | ) |
Sets the options related to number conversions for this QLocale instance.
Definition at line 1276 of file qlocale.cpp.
QString QLocale::standaloneDayName | ( | int | day, |
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().
Definition at line 3112 of file qlocale.cpp.
QString QLocale::standaloneMonthName | ( | int | month, |
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().
Definition at line 3077 of file qlocale.cpp.
|
static |
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.
Definition at line 2960 of file qlocale.cpp.
QLocale::Territory QLocale::territory | ( | ) | const |
Returns the territory of this locale.
Definition at line 1439 of file qlocale.cpp.
|
static |
Returns the two-letter territory code for territory, as defined in the ISO 3166 standard.
{QLocale::AnyTerritory} an empty string is returned.Definition at line 1644 of file qlocale.cpp.
Returns a QString containing the name of territory.
Definition at line 1744 of file qlocale.cpp.
Qt::LayoutDirection QLocale::textDirection | ( | ) | const |
QString QLocale::timeFormat | ( | FormatType | format = LongFormat | ) | const |
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}.
Definition at line 2463 of file qlocale.cpp.
QString QLocale::toCurrencyString | ( | double | value, |
const QString & | symbol = QString(), | ||
int | precision = -1 ) const |
Definition at line 4825 of file qlocale.cpp.
Returns a localized string representation of value as a currency. If the symbol is provided it is used instead of the default currency symbol.
Definition at line 4770 of file qlocale.cpp.
QString QLocale::toCurrencyString | ( | qulonglong | value, |
const QString & | symbol = QString() ) const |
Definition at line 4797 of file qlocale.cpp.
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
.
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.
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
.
Notice that the last conversion returns 1234.0, because '.' is the thousands group separator in the German locale.
This function ignores leading and trailing whitespace.
Definition at line 2139 of file qlocale.cpp.
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.
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.
Definition at line 2113 of file qlocale.cpp.
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.
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.
Definition at line 1991 of file qlocale.cpp.
Returns the 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.
long QLocale::toLong | ( | QStringView | s, |
bool * | ok = nullptr ) const |
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.
Definition at line 2030 of file qlocale.cpp.
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.
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.
Definition at line 2071 of file qlocale.cpp.
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.
Definition at line 3553 of file qlocale.cpp.
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.
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.
Definition at line 1951 of file qlocale.cpp.
QString QLocale::toString | ( | const QDateTime & | dateTime, |
FormatType | format, | ||
QCalendar | cal ) const |
Returns a localized string representation of the given dateTime according to the specified format (see dateTimeFormat()), optionally for a specified calendar cal.
Definition at line 2350 of file qlocale.cpp.
QString QLocale::toString | ( | const QDateTime & | dateTime, |
FormatType | format = LongFormat ) const |
Definition at line 2374 of file qlocale.cpp.
QString QLocale::toString | ( | const QDateTime & | dateTime, |
QStringView | format ) const |
Definition at line 2335 of file qlocale.cpp.
QString QLocale::toString | ( | const QDateTime & | dateTime, |
QStringView | format, | ||
QCalendar | cal ) const |
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.
Definition at line 2326 of file qlocale.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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:
\table \header
'e'
'E'
'F'
'f'
except for INF and NAN (see below) The special precision value QLocale::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'
, 'F'
and 'G'
formats, "INF" and "NAN" are used instead. This does not vary with locale.
Definition at line 2899 of file qlocale.cpp.
Returns a localized string representation of the given date in the specified format.
If format is an empty string, an empty string is returned.
Definition at line 2180 of file qlocale.cpp.
QString QLocale::toString | ( | QDate | date, |
FormatType | format, | ||
QCalendar | cal ) const |
Returns a localized string representation of the given date according to the specified format (see dateFormat()), optionally for a specified calendar cal.
Definition at line 2242 of file qlocale.cpp.
QString QLocale::toString | ( | QDate | date, |
FormatType | format = LongFormat ) const |
Definition at line 2266 of file qlocale.cpp.
QString QLocale::toString | ( | QDate | date, |
QStringView | format ) const |
Definition at line 2227 of file qlocale.cpp.
QString QLocale::toString | ( | QDate | date, |
QStringView | format, | ||
QCalendar | cal ) const |
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.
Definition at line 2218 of file qlocale.cpp.
Returns a localized string representation of i.
Definition at line 2150 of file qlocale.cpp.
Returns a localized string representation of the given time according to the specified format.
If format is an empty string, an empty string is returned.
Definition at line 2193 of file qlocale.cpp.
QString QLocale::toString | ( | QTime | time, |
FormatType | format = LongFormat ) const |
Returns a localized string representation of the given time in the specified format (see timeFormat()).
Definition at line 2400 of file qlocale.cpp.
QString QLocale::toString | ( | 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.
Definition at line 2312 of file qlocale.cpp.
QString QLocale::toString | ( | qulonglong | i | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 2164 of file qlocale.cpp.
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.
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.
Definition at line 2011 of file qlocale.cpp.
Returns the unsigned 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.
ulong QLocale::toULong | ( | QStringView | s, |
bool * | ok = nullptr ) const |
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.
Definition at line 2050 of file qlocale.cpp.
|
inline |
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.
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.
Definition at line 2092 of file qlocale.cpp.
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.
Definition at line 3529 of file qlocale.cpp.
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.
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.
Definition at line 1971 of file qlocale.cpp.
QStringList QLocale::uiLanguages | ( | TagSeparator | separator = TagSeparator::Dash | ) | const |
List of locale names for use in selecting translations.
Each entry in the returned list is the name of a locale suitable to the user's preferences for what to translate the UI into. Where a name in the list is composed of several tags, they are joined as indicated by separator. Prior to Qt 6.7 a dash was used as separator.
For example, using the default separator QLocale::TagSeparator::Dash, if the user has configured their system to use English as used in the USA, the list would be "en-Latn-US", "en-US", "en". The order of entries is the order in which to check for translations; earlier items in the list are to be preferred over later ones. If your translation files use underscores, rather than dashes, to separate locale tags, pass QLocale::TagSeparator::Underscore as separator.
Returns a list of locale names. This may include multiple languages, especially for the system locale when multiple UI translation languages are configured. The order of entries is significant. For example, for the system locale, it reflects user preferences.
Prior to Qt 6.9, the list only contained explicitly configured locales and their equivalents. This led some callers to add truncations (such as from 'en-Latn-DE' to 'en') as fallbacks. This could sometimes result in inappropriate choices, especially if these were tried before later entries that would be more appropriate fallbacks.
Starting from Qt 6.9, reasonable truncations are included in the returned list after the explicitly specified locales. This change allows for more accurate fallback options without callers needing to do any truncation.
Users can explicitly include preferred fallback locales (such as en-US) in their system configuration to control the order of preference. You are advised to rely on the order of entries in uiLanguages() rather than using custom fallback methods.
Most likely you do not need to use this function directly, but just pass the QLocale object to the QTranslator::load() function.
Definition at line 4958 of file qlocale.cpp.
QList< Qt::DayOfWeek > QLocale::weekdays | ( | ) | const |
Returns a list of days that are considered weekdays according to the current locale.
Definition at line 3432 of file qlocale.cpp.
QString QLocale::zeroDigit | ( | ) | const |
Returns the zero digit character of this locale.
This is a single Unicode character but may be encoded as a surrogate pair, so is (since Qt 6.0) returned as a string. In most locales, other digits follow it in Unicode ordering - however, some number systems, notably those using U+3007 as zero, do not have contiguous digits. Use toString() to obtain suitable representations of numbers, rather than trying to construct them from this zero digit.
Definition at line 2808 of file qlocale.cpp.
|
friend |
Definition at line 992 of file qlocale.cpp.
|
friend |
|
friend |
|
friend |
|
friend |
Returns the hash value for key, using seed to seed the calculation.
Definition at line 1264 of file qlocale.cpp.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |