diff options
| -rw-r--r-- | src/controls/SpinBox.qml | 10 | ||||
| -rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 12 |
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, '') |
