Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
Description
There is something of a shortage of examples showing more interesting use of QLocale than simply forwarding a default-constructed one, or the system locale, to some function. that takes care of doing the right thing for that locale. Direct use of its public API is less common, but should be illustrated where we can think of use-case for it.
One of the things an application or a reusable component may reasonably offer its users is the ability to select a locale, whether for global use (via QLocale::setDefault()) or use by a single component (by calling its setLocale() or similar method). For this they need to obtain a list of available locales, using QLocale::matchingLocales(), and build a menu that displays a suitably localized name of each locale – using QLocale's nativeLanguageName() and nativeTerritoryName(), but with some suitable special-case for the system locale – and map the user's selection from among them back to the locale that produced the entry selected.
There is an example of such a selection in Qt Virtual Keyboard, but it is complicated by restricting its selection based on available keyboard configurations. The example envisioned here simply select based on what locales QLocale provides support for. It need do nothing more complicated than embed a QDateTimeEdit displaying a time (e.g. the current time at program start-up, or when the locale was last updated) to illustrate the effect of selecting a change of locale. We potentially want separate examples for Quick and Widgets (if so, please create sub-tasks).
Attachments
Issue Links
- relates to
-
QTBUG-112765 Create QLocaleSelector
-
- Open
-