diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index b31d4f78d4aa1959a606fb56f245663b4c3ec70d..e7e491515b2707a185c8f80d7ef73b71a5b66eaa 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 96b4d422380e128702aa4cce8c860f83f8c56d91..177a8fcb21def819da8c1de1ec8d4d5e22ae09ee 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() + } } }