Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
5.15
-
Ubuntu 20.04
Description
import QtQml 2.15 QtObject { property double value: Number.fromLocaleString("1,234.01") // 1) Does not work, system locale is en_US // property double value: Number.fromLocaleString(Qt.locale(), "1,234.01") // 2) Does not work, system locale is en_US // property double value: Number.fromLocaleString(Qt.locale(Qt.locale().name), "1,234.01") // 3) WORKS! onValueChanged: console.log("value:", value) Component.onCompleted: { console.log("Default locale:", Qt.locale().name, ", uiLanguages:", Qt.locale().uiLanguages[0]) } }
Output:
qml: Default locale: en_US , uiLanguages: en-US file:///home/user/work/projects/test/test_number_default_locale.qml:4: Error: Locale: Number.fromLocaleString(): Invalid format
Expected output:
qml: value: 1234.01 qml: Default locale: en_US , uiLanguages: en-US
If I instantiate Qt.locale using default locale name, it works as expected:
property double value: Number.fromLocaleString(Qt.locale(Qt.locale().name), "1,234.01")