Doc fix in QIntValidator::validate() and comment on a test

The doc said positive values for a negative range were intermediate
but the code actually rejects them if the value has an overt plus
sign, so make clear that intermediate is only for the case without a
sign. Incidentally comment on a test where it might not have been
obvious to the reader that a space is the locale's digit-grouping
chracter.

Change-Id: I3edab74fe8c2cbe8448c0e523676f1fd0d0d8a9f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 58f5ec35f108bca01489124e74e96018fd937ed4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Edward Welbourne 2023-02-21 18:24:30 +01:00 committed by Qt Cherry-pick Bot
parent eec2fb9380
commit b5fa546f5f
2 changed files with 7 additions and 6 deletions

View File

@ -331,12 +331,12 @@ QIntValidator::~QIntValidator()
or is a prefix of an integer in the valid range, returns \l Intermediate.
Otherwise, returns \l Invalid.
If the valid range consists of just positive integers (e.g., 32 to 100)
and \a input is a negative integer, then Invalid is returned. (On the other
hand, if the range consists of negative integers (e.g., -100 to -32) and
\a input is a positive integer, then Intermediate is returned, because
the user might be just about to type the minus (especially for right-to-left
languages).
If the valid range consists of just positive integers (e.g., 32 to 100) and
\a input is a negative integer, then Invalid is returned. (On the other
hand, if the range consists of negative integers (e.g., -100 to -32) and \a
input is a positive integer without leading plus sign, then Intermediate is
returned, because the user might be just about to type the minus (especially
for right-to-left languages).
Similarly, if the valid range is between 46 and 53, then 41 and 59 will be
evaluated as \l Intermediate, as otherwise the user wouldn't be able to

View File

@ -165,6 +165,7 @@ void tst_QIntValidator::validateFrench()
QIntValidator validator(-2000, 2000, 0);
validator.setLocale(QLocale::French);
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);
validator.fixup(s);