diff options
author | Filippo Cucchetto <filippocucchetto@gmail.com> | 2014-11-19 23:16:42 +0100 |
---|---|---|
committer | Filippo Cucchetto <filippocucchetto@gmail.com> | 2014-11-25 11:35:41 +0100 |
commit | ef45995bc59cff6299ca5b10b4acb4840c473172 (patch) | |
tree | df836fea5466b2e43409daa78f06b9867751d46e | |
parent | b1141eaa833cfada0d10f68017fb329e68c04869 (diff) | |
download | qtquickcontrols-ef45995bc59cff6299ca5b10b4acb4840c473172.tar.gz |
Fix Spinbox missing value change if minimumValue is set
The Spinbox validator considered invalid an intermediate value preventing the user for inserting a valid value.
Task-number: QTBUG-42342
Change-Id: I24d2f9f7d6fb9d5d4f96f81821b37a30421665a3
Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com>
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/controls/Private/qquickspinboxvalidator.cpp | 4 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/controls/Private/qquickspinboxvalidator.cpp b/src/controls/Private/qquickspinboxvalidator.cpp index afbc866c..2fec79e8 100644 --- a/src/controls/Private/qquickspinboxvalidator.cpp +++ b/src/controls/Private/qquickspinboxvalidator.cpp @@ -200,7 +200,9 @@ QValidator::State QQuickSpinBoxValidator::validate(QString &input, int &pos) con bool ok = false; qreal val = locale().toDouble(value, &ok); if (ok) { - if (state == QValidator::Acceptable) { + if (state == QValidator::Acceptable || + (state == QValidator::Intermediate && val >= 0 && val <= m_validator.top()) || + (state == QValidator::Intermediate && val < 0 && val >= m_validator.bottom())) { const_cast<QQuickSpinBoxValidator *>(this)->setValue(val); if (input != textFromValue(val)) state = QValidator::Intermediate; diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index f74386c9..71132ca9 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -132,7 +132,10 @@ Item { {tag: "-20", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_Return], value: -2, minimumValue: -10}, {tag: "-200", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_0, Qt.Key_Return], value: -20, minimumValue: -100}, {tag: "-2000", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_0, Qt.Key_0, Qt.Key_Return], value: -200, minimumValue: -1000}, - {tag: "-0123", input: [Qt.Key_Minus, Qt.Key_0, Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_Return], value: -123, minimumValue: -150} + {tag: "-0123", input: [Qt.Key_Minus, Qt.Key_0, Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_Return], value: -123, minimumValue: -150}, + + {tag: "5", input: [Qt.Key_2, Qt.Key_0, Qt.Key_Return], value: 20, minimumValue: 10, maximumValue: 99}, + {tag: "-5", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_Return], value: -20, minimumValue: -99, maximumValue: -10}, ] } |