Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15
-
None
Description
In the ListView below, the current item should always be visible when new items are added. Instead, it's only visible if clipping isn't used.
import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 2.15 ApplicationWindow { width: 400 height: 400 title: "currentIndex: " + layerListView.currentIndex visible: true ListView { id: layerListView objectName: "layerListView" boundsBehavior: ListView.StopAtBounds width: 200 height: 200 anchors.centerIn: parent clip: clipCheckBox.checked currentIndex: 5 model: ListModel { ListElement { display: "0" } ListElement { display: "1" } ListElement { display: "2" } ListElement { display: "3" } ListElement { display: "4" } ListElement { display: "5" } } delegate: Text { text: display width: layerListView.width verticalAlignment: Text.AlignVCenter height: 40 font.bold: { print(index, layerListView.currentIndex) layerListView.currentIndex === index } required property int index required property string display Rectangle { anchors.fill: parent color: "#aacccccc" z: -1 } } Rectangle { anchors.fill: parent color: "transparent" border.color: "tomato" } } footer: ToolBar { RowLayout { CheckBox { id: clipCheckBox text: "Clip" } ToolButton { text: "Add item" onClicked: { layerListView.model.insert(layerListView.currentIndex, { display: "new item" }) layerListView.positionViewAtIndex(layerListView.currentIndex, ListView.Contain) } } } } }