Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.2
-
None
Description
ListView allows you to use the headerPositioning: property make a header float above the delegates as the view scrolls, but GridView does not.
Example ListView code that implements this feature:
import QtQuick import QtQuick.Controls as ControlsItem { width: 500 height: 500 ListView { id: listview anchors.fill: parent model: 50 delegate: Controls.ItemDelegate { width: listview.width text: index } headerPositioning: ListView.OverlayHeader header: Rectangle { z: 999 width: listview.width height: 20 color: "pink" Text { anchors.fill: parent text: "I'm a header" } } } }
Because GridView lacks the headerPositioning: property, it can't do the same thing, so the header always scrolls away.
Consider this code that illustrates the problem:
import QtQuickItem { width: 500 height: 500 GridView { id: gridview readonly property int cellSize: 200 cellWidth: cellSize + 10 cellHeight: cellSize + 10 anchors.fill: parent model: ListModel { ListElement { name: "Apple" } ListElement { name: "Orange" } ListElement { name: "Banana" } ListElement { name: "Apricot" } ListElement { name: "Pineapple" } ListElement { name: "Pointed Stick" } } delegate: Rectangle { width: gridview.cellSize height: gridview.cellSize radius: 5 color: "lightblue" Text { anchors.centerIn: parent text: model.name } } // headerPositioning: ListView.OverlayHeader // Missing! header: Rectangle { z: 999 width: gridview.width height: 20 color: "pink" Text { anchors.fill: parent text: "I'm a header" } } } }