Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.10, 6.2.5, 6.3.1, 6.4.0 Beta2
-
1
-
a79de46ac5 (qt/qtbase/dev) a79de46ac5 (qt/tqtc-qtbase/dev) 590d01c36c (qt/qtbase/6.4) 590d01c36c (qt/tqtc-qtbase/6.4) f85b2ed59c (qt/qtbase/6.3) f85b2ed59c (qt/tqtc-qtbase/6.3) a79de46ac5 (qt/qtbase/wip/protobuf) a79de46ac5 (qt/tqtc-qtbase/wip/protobuf)
-
Foundation Sprint 63
Description
https://doc.qt.io/qt-6/qdoublevalidator.html#validate says, "If notation() is set to StandardNotation, and the input contains more digits before the decimal point than a double in the valid range may have, Invalid is returned."
However, this is not always the case.
Code
#include <QGuiApplication> #include <QDoubleValidator> #include <QDebug> void testValidator(double bottom, double top, int decimals) { QDoubleValidator v(bottom, top, decimals); v.setNotation(QDoubleValidator::StandardNotation); QString input("1234.0"); int pos; static int i = 1; qDebug()<< "\nTEST" << i++; qDebug() << "Notation:" << v.notation(); qDebug() << "Input:" << input; qDebug() << "Range:" << QString("[%1, %2]").arg(v.bottom()).arg(v.top()); qDebug() << "Result:" << v.validate(input, pos); } int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); QLocale::setDefault(QLocale::c()); qDebug() << "Locale:" << QLocale(); testValidator(0.0, 99.0, 2); testValidator(0.0, 99.9, 2); testValidator(0.0, 100.0, 2); return 0; }
Results
Locale: QLocale(C, Default, Default) TEST 1 Notation: QDoubleValidator::StandardNotation Input: "1234.0" Range: "[0, 99]" Result: QValidator::Invalid TEST 2 Notation: QDoubleValidator::StandardNotation Input: "1234.0" Range: "[0, 99.9]" Result: QValidator::Intermediate TEST 3 Notation: QDoubleValidator::StandardNotation Input: "1234.0" Range: "[0, 100]" Result: QValidator::Invalid
TEST 2 gave the wrong results.