Important: Please read the Qt Code of Conduct -

PathView keypressed handling could be better

  • Hello all,

    PathView works great when you flick it but not so great when you use key presses. If you keep a key pressed for a while, you get key repeats that make the current index change very quickly (this is normal behavior). The thing is that if there aren't many items in the PathView (ex: 10), the animation doesn't have time to start moving towards one item that it has to move towards another in the other direction. What ends up happening is that the list skips around instead of turning around in one direction as you'd expect it.

    A way to fix this would be that instead of making the graphics go to the current index that remains in the bounds of the list, it should go to an index on which you don't apply a modulo. For example, it the bounds are [0..9], when you get to index 9, incrementing would get the "graphical index" to 10 and not 0. That way, the graphics keep on spinning until it reaches 10 which visually is the next 0.

    In the mean time, I have set highlightMoveDuration to 100 (default is 300ms). That way the spin is so fast that this problem doesn't occur. That said, a proper fix would be welcome.

    Cheers :)

  • Here is an example:

    @import QtQuick 1.0

    Rectangle {
    width: 150; height: 150
    property real itemSize: 20

     PathView {
         id: spinner
         anchors.fill: parent
         model: 10
         delegate: Text { text: index; font.pointSize: itemSize - 4}
         focus: true
         //highlightMoveDuration: 100
         path: Path {
             startX: width - itemSize; startY: -itemSize/2
             PathLine { x: width - itemSize; y: spinner.count * itemSize}
         Keys.onDownPressed: decrementCurrentIndex()
         Keys.onUpPressed: incrementCurrentIndex()
     Text {
          text: "Press Up/Down to spin\nCurrent item index: " + spinner.currentIndex


    Keep the Up or Down key pressed and you will see the numbers not spinning around as you'd expect.
    Remove the commented line to have it spin properly (but too fast...).

  • Hi,

    Thanks for the information and example -- would you be able to add it as an official bug report using (that way it is much more likely to be addressed, progress can be tracked, etc)?


  • Hi Michael,

    I have created a new entry in the official bug report as you suggested:

    Cheers :)

Log in to reply