ListView wrap around



  • Hi,
    I am trying to get a ListView to wrap around and I don't know why it isn't working. I set keyNavigationWraps to true but this doesn't seem to work with the Flick and also I don't know what key presses this is tied to.

    Here is my code:
    @
    import QtQuick 1.0

    Rectangle {
    id: mainWindow
    width: 800; height: 600
    color: "#0E113D"

    Column {
        anchors.fill: parent
        z: 1
        MyHeader{
            id: header
            anchors.top: parent.top
            anchors.horizontalCenter: parent.horizontalCenter
        }
    
        //list view will display a model according to a delegate
        ListView {
            id: myListView
            width:parent.width; height: parent.height - header.height
    
            //the model contains the data
            model: myListModel
    
            //control the movement of the menu switching
            snapMode: ListView.SnapOneItem
            orientation: ListView.Horizontal
            boundsBehavior: Flickable.StopAtBounds
            flickDeceleration: 5000
            highlightFollowsCurrentItem: true
            highlightMoveDuration:240
            highlightRangeMode: ListView.StrictlyEnforceRange
            keyNavigationWraps: true
        }
    }
    
    VisualItemModel {
        id: myListModel
    
        FirstView {
            id: firstView
            width: myListView.width; height: myListView.height
        }
        SecondView {
            id: secondView
            width:  myListView.width; height: myListView.height
        }
        ThirdView {
            id: thirdView
            width:  myListView.width; height: myListView.height
        }
    }
    

    }@

    What I want is when you flick right on thirdView for it to go back to firstView. Likewise, if you flick left on firstView, it should go to thirdView. Also, if there is a quick answer to how to bind key presses, I'd appreciate it.
    Thanks.



  • You could use a pathview to do that. A pathview is wrapping, a listview is not.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.