Important: Please read the Qt Code of Conduct -

QML PathView: change current index of pathview via mouse wheel

  • I have created a path view with a delegate and model. Is it possible to change current index of the PathView via mouse wheel instead of mouse click drag?

    Following is my PathView code:

    @PathView {
    id: pathView;
    anchors.fill: parent;
    model: sampleModel;
    delegate: delegate;
    path: Path {
    startX: 45; startY: 100
    PathAttribute { name: "iconScale"; value: 0.3 }
    PathAttribute { name: "iconOpacity"; value: 0.1 }
    PathQuad { x: 45; y: 300; controlX: 45; controlY: 200 }
    PathAttribute { name: "iconScale"; value: 1 }
    PathAttribute { name: "iconOpacity"; value: 1 }
    PathQuad { x: 45; y: 500; controlX: 45; controlY: 400 }

  • Hey,

    i would go ahead and create a MouseArea where ever you need to catch the Mousewheel event. As you can see in the documentation, there is a onWheel(WheelEvent wheel) event.

    bq. This handler is called in response to both mouse wheel and trackpad scroll gestures.
    The wheel parameter provides information about the event, including the x and y position, any buttons currently pressed, and information about the wheel movement, including angleDelta and pixelDelta.

    Just create the notification in your MouseArea using onWheel: and handle it on your purpuses, that means increase or decreate the currentIndex of your PathView.

    For further information please read:
    "MouseArea onWheel":

Log in to reply