Qt::QLocale

目的

QLocale:地方

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

因此本质来说: 它是一个<语言、国家> pair.

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

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

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

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

在应用程序启动时,QLocale 支持由系统本地配置中决定的default locale;

当前< language/country >pair 有构造函数确定后, 可能会有如下三种情况发生。

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

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

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

If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).
Use language() and country() to determine the actual language and country values used.


Note: For the current keyboard input locale take a look at QInputMethod::locale().
获取输入法本地的locale

最终

最终获取的是数据来源于windows 区域格式设置。如下图所示:
Qt::QLocale_第1张图片

你可能感兴趣的:(Qt,locale)