Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 6.2
- Window {
- id: root
- visible: true
- width: 800
- height: 600
- title: qsTr("Qt 6.2.1 ListView Bug")
- Component {
- id: listViewHeader
- Rectangle {
- z: 2
- color: "black"
- clip: true
- height: columnName.implicitHeight + 10
- width: myListView.width
- Text {
- id: columnName
- color: "white"
- text: qsTr("Row Name")
- }
- }
- }
- Component {
- id: listDelegate
- Rectangle {
- color: Qt.rgba(Math.random(), Math.random(), Math.random(), 0.25)
- clip: true
- height: rowText.implicitHeight + 10
- width: myListView.width
- Text {
- id: rowText
- text: model.display
- }
- }
- }
- ListView {
- id: myListView
- anchors.fill: parent
- // BUG! If the ListView has a header and the view is not moved so that item 0
- // is still shown when the model is reset, then the ListView renders a phantom
- // item 0 that is no longer in the model. If new model has an item 0 it is
- // rendered right over the top of the phantom item 0.
- header: listViewHeader
- headerPositioning: ListView.OverlayHeader
- model: pythonModel
- delegate: listDelegate
- clip: true
- focus: true
- }
- Connections {
- target: pythonModel
- function onModelAboutToBeReset() {
- console.log("onModelAboutToBeReset model.rowCount=", pythonModel.rowCount())
- }
- }
- Connections {
- target: pythonModel
- function onModelReset() {
- console.log("onModelReset model.rowCount=", pythonModel.rowCount())
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment