Is there a way to get the row number of a QML TreeView
when selecting/clicking something on the TreeView
? For example, for a TableView
I use currentRow
. Is there something equivalent for a TreeView
?
Asked
Active
Viewed 1,091 times
0

Francisco Hernandez
- 312
- 5
- 18
1 Answers
1
You should use currentIndex
. More info in the documentation.
For example:
TreeView {
id: myTree
...
model: myModel
onCurrentIndexChanged: console.log("current index: " + currentIndex
+ " current row: " + currentIndex.row)
TableViewColumn {
title: "title1"
role: "role1"
}
TableViewColumn {
title: "title2"
role: "role2"
}
onClicked: {
console.log("clicked", index)
}
}
You can check the complete example in GitHub.

Tarod
- 6,732
- 5
- 44
- 50