Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ListView elements not visible fully.



  • Hi,
    I am trying to create a series of button using listview.
    Problem I face is,

    1. Even on slow swipe, Flick ended signal should trigger
    2. Highlighted item does not visible fully after swipe. Example last element i.e 13 is highlighted, and its moved out of visible area to its right, then it doesn't resume back being fully visible.
    3. When Spring backs to first element, how to remove animation?

    import QtQuick 2.12
    import QtQuick.Window 2.0
    import QtQuick.Controls 2.12
    import QtGraphicalEffects 1.0

    ApplicationWindow {
    id: root
    width: 438
    height: 102

    Component.onCompleted: {
        list.currentIndex = 0
        list.positionViewAtBeginning()
    }
    
    ListView {
        id: list
        anchors.fill: parent
        focus: true
        clip: true
        anchors.leftMargin: 12
        anchors.rightMargin: 12
        spacing: 12
        model: 14
        delegate:
            Button {
            id: button
            text: index
            width: list.currentIndex === index ? 82 : 50
            height: list.currentIndex === index ? 82 : 50
            y: list.currentIndex === index ? 9 : 18
            onClicked: list.currentIndex = index
            focus: true
            antialiasing: true
        }
        orientation: ListView.Horizontal
        highlightFollowsCurrentItem: true
        boundsBehavior: Flickable.StopAtBounds
        onFlickEnded: positionViewAtIndex(currentIndex, ListView.Visible)
    }
    

    }

    Thanks in advance.


Log in to reply