Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
6.5.0
-
None
-
Linux: gcc x86_64
Windows: MSVC 2019 / 2022 x64
Description
The example given in Qt docs https://doc.qt.io/qt-6/qlocale.html#toDouble does not work as expected and the result is different on different Linux computers / Windows.
The following test does not work on our Linux build server but on my desktop Linux:
QLocale::setDefault(QLocale(QLocale::German, QLocale::Germany)); const QString englishFloat = "3.5"; const QString germanFloat = "3,5"; bool myOK = false; /* On my Linux desktop and the Linux build server: result = 3.5, ok = true On my windows desktop result = 0, ok = false */ float result = QLocale::system().toFloat(englishFloat, &myOK); /* On my Linux desktop and windows desktop: result = 3.5, ok = true on my Linux build server result = 0, ok = false */ result = QLocale::system().toFloat(germanFloat, &myOK);
With Qt 5.15.2, QString::number() would give me for both strings the result 3.5 without setting any QLocale. That would be my desired result...