QML ListView contentX is updated despite highlightFollowCurrentItem: false
-
Hi,
I want to make ListView, which would ignore currentIndex/currentItem changes and would keep specified content position unchanged, no matter what.
I've usedhighlightFollowsCurrentItem: falsefor that (see example below). And when you increment current index (e.g. by pressing 'down')contentXremains unchanged, even if current item is no longer visible. But if you changecontentXmanually so it's not in the beginning (press 'space') and start decrementing current index -contentXwill be updated once current item is no longer visible. Without animation (seeBehavior on contentXbelow). Is that expected behavior? I couldn't find documentation which describes this behaviour.
I'm using Qt 5.9.4import QtQuick 2.9 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") ListView { id: listView focus: true anchors.fill: parent orientation: ListView.Vertical model: 20 spacing: 10 keyNavigationEnabled: true highlightFollowsCurrentItem: false delegate: Rectangle { height: 100 width: listView.width color: ListView.isCurrentItem ? 'green' : 'orange' Behavior on color { ColorAnimation {} } Text { anchors.centerIn: parent text: index } } Behavior on contentX { NumberAnimation {} } Keys.onPressed: { if (event.key === Qt.Key_Space) { contentY = contentHeight - height; event.accepted = true; return; } } } }