summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-03-07 14:29:15 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-07 18:33:05 +0100
commitc58290ee7af6f2abcd08cbf319ff6f85b9db9fdb (patch)
treea05314476cbbb57cfb4983d63fd2671308ebec79
parent8c142768e42c450c14225b1d9354836aec0b0126 (diff)
downloadqtquickcontrols-c58290ee7af6f2abcd08cbf319ff6f85b9db9fdb.tar.gz
Fix initialization value of SpinBox
The maximumValue 99 was enforced on value _before_ we had a chance to update it. This made it sometimes impossible to get a maximumValue higher than 99. Change-Id: Ia07a9271d563fd3496b583757df757c1e7b4ceb5 Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
-rw-r--r--src/controls/SpinBox.qml10
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml12
2 files changed, 20 insertions, 2 deletions
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index 4b6d4e85..c82e3410 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -153,6 +153,8 @@ Control {
}
/*! \internal */
+ property bool __initialized: false
+ /*! \internal */
readonly property bool __upEnabled: value != maximumValue;
/*! \internal */
readonly property bool __downEnabled: value != minimumValue;
@@ -196,9 +198,13 @@ Control {
/*! \internal */
onMinimumValueChanged: input.setValue(value)
/*! \internal */
- Component.onCompleted: input.setValue(value)
+ Component.onCompleted: {
+ __initialized = true;
+ input.setValue(value)
+ }
+
/*! \internal */
- onValueChanged: input.setValue(value)
+ onValueChanged: if (__initialized) input.setValue(value)
Accessible.name: input.text
Accessible.role: Accessible.SpinBox
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index e3105384..b725b88a 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -255,6 +255,18 @@ Item {
compare(spinbox.value, spinbox.maximumValue)
}
+ function test_initialization_order()
+ {
+ var spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; SpinBox { id: spinbox;" +
+ "maximumValue: 2000; value: 1000; implicitWidth:80}",
+ container, '')
+ compare(spinbox.value, 1000);
+
+ spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox { minimumValue: -1000 ; value:-1000}',
+ container, '')
+ compare(spinbox.value, -1000);
+ }
+
function test_ImplicitSize() // Verify if we correctly grow and shrink depending on contents
{
var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')