summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/util/qvalidator.cpp3
-rw-r--r--tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp11
2 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index 49945ae5b0..6231a097d3 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -862,7 +862,8 @@ QRegExpValidator::~QRegExpValidator()
partially (i.e. could be a valid match if additional valid
characters are added), and \l Invalid if \a input is not matched.
- The \a pos parameter is set to the length of the \a input parameter.
+ Additionally, if \a input is not matched, the \a pos parameter is set to
+ the length of the \a input parameter.
For example, if the regular expression is \b{\\w\\d\\d}
(word-character, digit, digit) then "A57" is \l Acceptable,
diff --git a/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp b/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp
index 7a2006b62e..d09a8e566b 100644
--- a/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp
+++ b/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp
@@ -116,8 +116,15 @@ void tst_QRegExpValidator::validate()
QSignalSpy changedSpy(&rv, SIGNAL(changed()));
rv.setRegExp( QRegExp( rx ) );
- int dummy;
- QCOMPARE( (int)rv.validate( value, dummy ), state );
+ int pos = -1;
+
+ QCOMPARE( (int)rv.validate( value, pos ), state );
+
+ if (state == QValidator::Invalid)
+ QCOMPARE(pos, value.length());
+ else
+ QCOMPARE(pos, -1); // untouched on Acceptable or Intermediate
+
QCOMPARE(spy.count(), 1);
QCOMPARE(changedSpy.count(), 1);
}