diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-02-21 18:24:30 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-05 06:22:09 +0000 |
commit | b5fa546f5f909b3f88bf909ca1f186f2b0b68780 (patch) | |
tree | 343b5fa41023ea89aaaa6d3fa03e813447145d69 | |
parent | eec2fb9380e5dcf007de46d3eec517b537284eec (diff) | |
download | qtbase-b5fa546f5f909b3f88bf909ca1f186f2b0b68780.tar.gz |
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>
-rw-r--r-- | src/gui/util/qvalidator.cpp | 12 | ||||
-rw-r--r-- | tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp | 1 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 84f40a6226..8b0f9ac321 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -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 diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp index ec4e3930ec..5b0f30cf9a 100644 --- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp @@ -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); |