Search code examples
qttreeviewqmlqt-quick

How to know when a TreeView Node is closed ( not Expanded)


I found in the doc TreeView doc that you can use onExpanded to know when a Node from a TreeView is expanded but how can you know when a Node is closed ?

Code example:

TreeView {
    TableViewColumn {
        title: "Name"
        role: "fileName"
        width: 300
    }
    TableViewColumn {
        title: "Permissions"
        role: "filePermissions"
        width: 100
    }
    model: fileSystemModel

    onExpanded {
       console.log("expanded :" + index)
    }
}

Solution

  • From the documentation, onCollapsed is the opposite of onExpanded, so you can check when that signal is emitted.