How to managment the position of the item in the ListView during the scrolling

I have the list view. When I scroll items the top element can stop any position and can be seen half height. enter image description here But I need that after scrolling stop the top element can be seen full height.enter image description here

import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.12

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Scroll")

    ColumnLayout {
        anchors.fill: parent

        RowLayout {
            id: buttonsRow
            Button {
                text: "Open dump file"
            }
            Button {
                text: "Copy raw data to clipboard"
            }
        }

        ListView {
            id: listView
            flickableDirection: Flickable.VerticalFlick
            boundsBehavior: Flickable.StopAtBounds
            model: 100
            clip: true
            delegate: ItemDelegate {
                text: modelData

                Rectangle
                {
                    width: parent.width   - 5
                    height: parent.height - 5

                    color: "green"
                }
            }

            Layout.fillWidth: true
            Layout.fillHeight: true

            ScrollBar.vertical: ScrollBar {}
        }
    }
}

Upvotes: 0

Views: 667

Answers (1)

augre
augre

Reputation: 2051

Use the snapMode property:

ListView {
   snapMode: ListView.SnapToItem
   // ...
}

Upvotes: 2

Related Questions