ListView inside PathView = broken touchscreen scrolling
-
I'm developing an application using PySide 6.9 that features lists of items encapsulated inside a carousel.
For that I used a PathView with a horizontal path (since I prefer its looping), with a vertical ListView inside its delegate. When testing this configuration with mouse, I get expected results (horizontal swipe scrolls the PathView, vertical - ListView), but when I try the same with a touchscreen device (running Windows 10 and Linux Mint), when I swipe horizontally (over an area covered by a ListView) it scrolls only for a couple pixels at a time before stopping, what is also interesting, after scrolling in such a way, the PathView doesn't snap back to preferredHighlightBegin/preferredHighlightEnd.When I build a similar configuration but using two nested ListViews instead, outer Horizontal, inner Vertical, I observe expected behavior (same smooth scrolling both both ways as when using mouse), but I lose the desired looping.
Can I consider it a bug of the implementation?
Do any workarounds for this behavior exist?Minimal example attached
import QtQuick Window { id: root width: 800; height: 600 visible: true PathView { anchors.fill: parent model: 6 pathItemCount: 3 preferredHighlightBegin: 0.5 preferredHighlightEnd: 0.5 highlightRangeMode: ListView.StrictlyEnforceRange dragMargin: height / 2 path: Path { startX: -root.width * 0.3 startY: root.height / 2 PathLine { x: root.width * 1.3 y: root.height / 2 } } delegate: Rectangle { width: root.width / 2 height: PathView.view.height color: "#888888" ListView { anchors.fill: parent anchors.leftMargin: 5 anchors.rightMargin: 5 spacing: 5 model: 6 delegate: Rectangle { width: ListView.view.width height: 40 color: "white" } } } } }
-
I would make my model looping as a workaround.
Maybe a proxy model working with your view? Exposing 1 mirror of your model before the1 2 3 4 1 2 3 4 1 2 3 4 x <-- start index of your view
Ensure that the index is always in the middle part of the model.
If the current index of the views goes in the first part, "remove" the last part and "insert" a new mirror part in front so that the index is now in the middle again. Same thing if it goes to the last part, shift the first part at the end.