Important: Please read the Qt Code of Conduct -

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


Log in to reply