Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. //main.qml
  2.  
  3. TreeView {
  4. id: treeView
  5. anchors.fill: parent
  6. model: treeviewmodel
  7. selection: ItemSelectionModel {
  8. model: treeviewmodel
  9. }
  10. TableViewColumn {
  11. role: "name_role"
  12. title: "Section Name"
  13. }
  14. onCollapsed: {
  15. treeView.selection.clearCurrentIndex() //deselects the item, but does not clear the row values
  16. treeView.selection.clearSelection()
  17. }
  18. onExpanded: {
  19. treeView.selection.clearCurrentIndex()
  20. treeView.selection.clearSelection()
  21. }
  22. onClicked: {
  23. console.log("Current Row: " + treeView.currentIndex.row + "Parent Row: " + treeView.currentIndex.parent.row)
  24. //I need something here that will set treeView.currentIndex.row and treeView.currentIndex.parent.row to -1
  25. //so that when I collapse or expand, -1 gets passed instead of the previous values
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement