Qt 6.11 is out! See what's new in the release
blog
Tumbler doesn't respond on mouse wheel
-
Hi! I need to use Tumbler in my project (Qt 6.11), but it doesn't seem to respond to mouse wheel (responds to touch though). I was expecting it to be out of the box behavior. How to make it work?
Window { width: 640 height: 800 visible: true title: qsTr("Hello World") Tumbler { id: testTumbler width: 200 height: 600 model: ["1", "2", "3", "4", "5"] wheelEnabled: true } }I tried
Tumbler { id: testTumbler width: 200 height: 600 model: ["1", "2", "3", "4", "5"] wheelEnabled: true hoverEnabled: true focus: hovered }It didn't help.
-
You should take a look at examples by QT for Tumbler QML;
Try this, or parts of this code, this works for me;
import QtQuick import QtQuick.Controls Window { id: window width: 640 height: 480 visible: true title: qsTr("Mouse wheel action") Rectangle { color: "khaki" anchors.centerIn: parent width: frame.implicitWidth + 10 height: frame.implicitHeight + 10 Frame { id: frame anchors.centerIn: parent Row { id: row Tumbler { id: tumbler model: 5 width: 200; height: width focus: true; wheelEnabled: false delegate: Text { text: modelData font.pixelSize: 18 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter opacity: 1.0 - Math.abs(Tumbler.displacement) / (tumbler.visibleItemCount / 2) required property var modelData required property int index } } WheelHandler { onWheel: (event) => { tumbler.currentIndex += event.angleDelta.y > 0 ? -1 : 1 } } } } } }p.s. My mouse is old and the scroll wheel is very intermittent, but I think the above should help.