When using QLocale::setDefault("de_DE") for setting the localization to German (or to any other localization which does not use pm or am suffixes) QLocale's DateTime format returns (0,2) for amText and for pmText like intended as there is no am or pm suffixes in use in the German language. But when amText and pmText is explicitly requested the Qt will fallback for providing "AM" and "PM" texts instead of "" which is the case when localization is based on system localization on Windows.
These two methods are inconsistent with each other.
I have attached an example which reproduces the problem.
How to reproduce:
1. Change the localization of system to German (Germany).
2. Build and run the attached example with Qt 5.15.x
3. Please look at the output. The am & pm are different when comparing the system localization and the localization from data used internally with Qt.
The output is the following:
empty (default from system) "de_DE" "" "" "dddd d. MMMM yyyy H.mm.ss" ""
empty (after setDefault() ) "de_DE" "PM" "AM" "dddd, d. MMMM yyyy HH:mm:ss t" "PM"
empty (after set to sysLocale) "de_DE" "" "" "dddd d. MMMM yyyy H.mm.ss" ""
When they would be expected to be the same.