From 5c1bc5c8a41e9d4b40161eae1413bcb69325dd8f Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 27 Mar 2020 14:10:43 +0100 Subject: QLineEdit: clarify the impact of using validators Values that are validated as Intermediate are possible to enter, but returnPressed and editingFinished signals are not emitted. Fixes: QTBUG-82915 Change-Id: I3e194cd6ee93b3402090117b67044cf3663a232e Reviewed-by: Paul Wicking Reviewed-by: Edward Welbourne --- src/gui/util/qvalidator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 54cbb28ffa..6e87faf534 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -370,8 +370,9 @@ QIntValidator::~QIntValidator() \fn QValidator::State QIntValidator::validate(QString &input, int &pos) const Returns \l Acceptable if the \a input is an integer within the - valid range, \l Intermediate if the \a input is a prefix of an integer in the - valid range, and \l Invalid otherwise. + valid range. If \a input has at most as many digits as the top of the range, + 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 @@ -380,6 +381,10 @@ QIntValidator::~QIntValidator() 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 + change a value from 49 to 51. + \snippet code/src_gui_util_qvalidator.cpp 2 By default, the \a pos parameter is not used by this validator. -- cgit v1.2.3