QML TreeView



  • Hi
    I need to implement a QML TreeView representing some data.
    The representation requires that rows have to be displayed differently - for example some rows have a checkbox some dont.
    I have managed to get all rows to have a checkbox but cant understand how to style each row differently.
    This is what I have so far

    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        TreeView {
            model: myModel
    
            alternatingRowColors: false
            anchors.fill: parent
    
            headerDelegate: {
                visible: false
            }
    
            TableViewColumn {
                title: "Name"
                role: "display"
                width: 300
            }
    
    
            itemDelegate: Item {
                id: itemId
    
                CheckBox {
                    anchors.verticalCenter: parent.verticalCenter
                    text: styleData.value
                }
            }
        }
    }
    

    And this is what I am aiming for
    0_1554199731131_df910128-4d66-4acb-876e-8f368d77f047-image.png

    Thanks


Log in to reply