From 08269077b3dc88751cbeb110e18571e27c912e98 Mon Sep 17 00:00:00 2001 From: Oliver Eftevaag Date: Tue, 2 Aug 2022 14:28:56 +0200 Subject: Flickable: let changing contentItem pos also affect the drag starting pos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When calling the setContentX(qreal) and setContentY(qreal) functions, the flickable would not update the drag starting position if they were called in the middle of a dragging operation. This patch makes those function update the drag starting position, so that the drag will take into account the external changes to the contentItem position, and not make any massive leaps on the next call to drag() after changing the contentItem position directly. Note that vData.pressPos and hData.pressPos are set to the x and y position of the contentItem at the beginning of a drag operation. They are unrelated to the mouse position. The bug QTBUG-104966 will be fixed from this, since QQuickItemView::setModel() calls QQuickListViewPrivate::setPosition() which calls QQuickFlickable::setContentX/Y(). The QQuickFlickable::setContentX/Y functions are public (part of the public API). They will update the timeline value for the x and y axis, which will as a result also call setViewportX/Y, which calls setX/Y for the contentItem itself. Done-with: Jan Arve Sæther Fixes: QTBUG-104966 Change-Id: Id5165e1ff37a07b94be8c1cc152e86dfcc13d1c6 Reviewed-by: Oliver Eftevaag Reviewed-by: Jan Arve Sæther (cherry picked from commit 5647527a8cde84b51fff66fc482f02435770b3dd) --- .../data/contentPosWhileDragging.qml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml (limited to 'tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml') diff --git a/tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml b/tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml new file mode 100644 index 0000000000..57a4273257 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml @@ -0,0 +1,22 @@ +import QtQuick 2.14 + +Item { + id: root + width: 500 + height: 500 + Flickable { + anchors.centerIn: parent + width: 100 + height: 100 + clip: true + contentWidth: content.width + contentHeight: content.height + Rectangle { + id: content + width: 320 + height: width + color: "#41cd52" + radius: width/2 + } + } +} -- cgit v1.2.3