Hi all,

Im trying to create a simple treeView appeared in Qt 5.5 , the problem is that the text in items of the tree doesn't display, despite the model is full.

There is my code :

TreeViewPM.qml

Qt Code:
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.4
  3. import QtQml.Models 2.2
  4. import KMTreeModelPM 1.0
  5.  
  6. Item {
  7.  
  8. KMTreeModelPM {
  9. id: treeModel
  10. }
  11.  
  12. ItemSelectionModel {
  13. id: sel
  14. model: treeModel
  15. }
  16. Text {
  17. id:txt
  18. text: " "
  19. }
  20.  
  21.  
  22. TreeView {
  23. id: view
  24. anchors.fill: parent
  25. anchors.margins: 12
  26. selection: sel
  27. headerVisible : false
  28. itemDelegate: Rectangle {
  29. color: ( styleData.row % 2 == 0 ) ? "white" : "lightblue"
  30. height: 20
  31.  
  32. Text {
  33. anchors.verticalCenter: parent.verticalCenter
  34. anchors.left: parent.left // by default x is set to 0 so this had no effect
  35. text: styleData.value
  36. }
  37. }
  38. TableViewColumn {
  39. id : title
  40. title: "Title"
  41. role: "title"
  42. resizable: true
  43. horizontalAlignment : Text.AlignLeft
  44. }
  45. model: treeModel
  46.  
  47. onDoubleClicked: txt.text = treeModel.data(index,0)
  48.  
  49. }
  50.  
  51. }
To copy to clipboard, switch view to plain text mode 

main.qml

Qt Code:
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.4
  3. import QtQml.Models 2.2
  4. import QtQuick.Layouts 1.1
  5. import QtQuick.Controls.Styles 1.4
  6.  
  7. Rectangle {
  8. width: 785
  9. TabView {
  10. x: 17
  11. y: 8
  12. width: 970
  13. height: 800
  14. currentIndex: 2
  15. visible: true
  16. Tab {
  17. id: tabAddProfile
  18. title: qsTr("Add Profile")
  19. AddProfilePage{}
  20. }
  21. Tab {
  22. id: tabAddTypeSubType
  23. title: qsTr("Add Type/SubType")
  24. AddTypeSubTypePage{}
  25. }
  26. Tab {
  27. id: tabAddDetail
  28. height: 413
  29. visible: true
  30. title: qsTr("Add Detail")
  31. TreeViewPM {}
  32. }
  33.  
  34. }
  35.  
  36. }
To copy to clipboard, switch view to plain text mode