summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-06-04 11:03:39 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-04 11:53:11 +0200
commit1c7d06f2696465993d63a33bf4144f49f02552bc (patch)
treed6966462e67846834cc02f7dc65f38763264a57a
parent8db84cb14a049ff27ccc5893517d8c5ffe0fd636 (diff)
Fix warning in Slider when stepSize is set
Also adding a new test for stepSize Task-number: QTBUG-31441 Change-Id: Ib8d9cc2188b5f73b6b0ac866ade1a7edb1d662b7 Reviewed-by: Caroline Chao <caroline.chao@digia.com>
-rw-r--r--src/controls/Slider.qml16
-rw-r--r--tests/auto/controls/data/tst_slider.qml11
2 files changed, 19 insertions, 8 deletions
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml
index b31d4f78d..e7e491515 100644
--- a/src/controls/Slider.qml
+++ b/src/controls/Slider.qml
@@ -197,6 +197,14 @@ Control {
anchors.horizontalCenter: !__horizontal ? parent.horizontalCenter : undefined
width: __panel.handleWidth
height: __panel.handleHeight
+
+ function updatePos() {
+ if (updateValueWhileDragging && !mouseArea.drag.active)
+ range.position = __horizontal ? x : y
+ }
+
+ onXChanged: updatePos();
+ onYChanged: updatePos();
}
MouseArea {
@@ -247,14 +255,6 @@ Control {
}
}
- // Range position normally follows handle, except when
- // 'updateValueWhileDragging' is false.
- Binding {
- when: updateValueWhileDragging && !mouseArea.drag.active
- target: range
- property: "position"
- value: __horizontal ? fakeHandle.x : fakeHandle.y
- }
// During the drag, we simply ignore the position set from the range, this
// means that setting a value while dragging will not "interrupt" the
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 96b4d4223..177a8fcb2 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -282,5 +282,16 @@ Item {
verify(control.value > 0.5)
control.destroy()
}
+
+ function test_valueAndHandlePosition()
+ {
+ var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {minimumValue: 0; maximumValue: 100; width: 100; height: 20; stepSize: 1}', container, '');
+ slider.forceActiveFocus()
+ slider.value = 0
+ compare(slider.__handlePos, 0)
+ slider.value = 50
+ compare(slider.__handlePos, 50)
+ slider.destroy()
+ }
}
}