diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 0ba597f742..d15bdd93cd 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4297,6 +4297,12 @@ QLocaleData::validateChars(QStringView str, NumberMode numMode, int decDigits, } result.state = ParsingResult::Acceptable; + + // Intermediate if it ends with any character that requires a digit after + // it to be valid e.g. group separator, sign, or exponent + if (last == ',' || last == '-' || last == '+' || last == 'e') + result.state = ParsingResult::Intermediate; + return result; } diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 079c0dedc3..2a81006657 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -377,9 +377,6 @@ std::optional initialResultCheck(T min, T max, const ParsingR if (signConflicts) return QValidator::Invalid; - if (buff.size() == 1 && (ch == '-' || ch == '+')) - return QValidator::Intermediate; - if (result.state == ParsingResult::Intermediate) return QValidator::Intermediate; diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp index 5b0f30cf9a..756b1a9c01 100644 --- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp @@ -167,7 +167,8 @@ void tst_QIntValidator::validateFrench() int i; // Grouping separator is a narrow no-break space; QLocale accepts a space as it. QString s = QLatin1String("1 "); - QCOMPARE(validator.validate(s, i), QValidator::Acceptable); + // Shouldn't end with a group separator + QCOMPARE(validator.validate(s, i), QValidator::Intermediate); validator.fixup(s); QCOMPARE(s, s);