Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ScrollBar QML crash



  • Does anyone know why the following code crashes when the ListView anchors.margins is uncommented and the list's contentHeight grows larger than it's height?

    ApplicationWindow {
        width: 200
        height: 480
        visible: true
        title: qsTr("Hello World")
        color: "black"
    
        ListView {
            id: listView
            z: -1
            anchors.fill: parent
    //        anchors.margins: 10
            spacing: 10
            model: 1
    
            ScrollBar.vertical: ScrollBar {
                id: scrollBar
                visible: parent.contentHeight > parent.height
                padding: 20
            }
    
            delegate: Rectangle {
                width: parent.width - (scrollBar.visible ? scrollBar.width : 0)
                height: width
    
                MouseArea {
                    anchors { fill: parent }
    
                    onClicked: listView.model++
                }
            }
        }
    }
    

    Commenting out the anchors.margins causes it not to crash. Changing scrollBar.padding to 10 causes it not to crash.

    I can't figure out what's going on with ScrollBar here.


Log in to reply