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

How to change color of Tree view items on updation of model



  • Hi All,

    I have model in cpp which has list of module name and this Model i m setting to Treeview in Qml like below:
    In output i have to show tree structure for each module which has different erros and warnings ,

    TreeView {
    width: parent.width
    height: 200
    headerVisible: false
    backgroundVisible: true
    __horizontalScrollBar.visible: false
    frameVisible: false
    model: myModel //Model from cpp
    style: TreeViewStyle {
    backgroundColor: Colors.menuBodyBackground
    branchDelegate: Rectangle{
    width: 10
    height: 10
    color: Colors.menuBodyTextHeading2
    Image {
    anchors.centerIn: parent
    source: "qrc:/images/Simulate.svg"
    sourceSize: Qt.size(parent.width0.8,parent.height0.8)
    }
    }
    }

            TableViewColumn {
                role: "display"
                width:400
                delegate: tableItemDelegateText
            }
    

    Component {
    id:tableItemDelegateText
    Item {
    Text {
    font.pointSize: 11
    color:styleData.isExpanded ? Colors.treeViewRootItem : Colors.menuBodyTextHeading3
    elide: styleData.elideMode
    text: styleData.value === undefined ? "" : styleData.value
    }
    }
    }
    rowDelegate: Component {
    Rectangle {
    height: 20
    color: isSelected ? Colors.menuBodySelectedRowBackground : Colors.menuBodyBackground
    property bool isSelected: styleData.selected
    }
    }

    The Question is when ever a module receives a new error or warning i need to notify user by changing only perticular "Module" color into Red


Log in to reply