I am using import QtQuick.Controls 1.4 as CC. Whenever I click on any row, the output I get is only about the first rows's data. When I click on the second row, I still get first row's data.

What is the way to get data from second row?

Qt Code:
  1. import QtQuick.Window 2.12
  2. import QtQuick 2.12
  3. import QtQuick.Controls 1.4 as CC
  4. import QtQuick.Controls.Styles 1.4
  5.  
  6. Window
  7. {
  8. visible: true
  9. width: 640
  10. height: 480
  11. title: qsTr("Hello World")
  12.  
  13. CC.TableView
  14. {
  15. height: 400; width: 600
  16.  
  17. style: TableViewStyle
  18. {
  19. headerDelegate: Rectangle
  20. {
  21. height: 20
  22. color: "lightsteelblue"
  23. Text
  24. {
  25. width: parent.width
  26. text: styleData.value
  27. }
  28. }
  29.  
  30. rowDelegate: Rectangle
  31. {
  32. color: "blue"
  33. height: 30
  34.  
  35. MouseArea {
  36. id: ma
  37. anchors.fill: parent
  38. onClicked: {
  39.  
  40. console.log(styleData.value)
  41. console.log(mymodel.get(styleData.value).aaa)
  42.  
  43. console.log(mymodel.get(styleData.value).bbb)
  44. }
  45. }
  46.  
  47. }
  48. }
  49.  
  50. CC.TableViewColumn
  51. {
  52. role: "aaa"
  53. title: "AAA"
  54. width: 100
  55.  
  56. delegate: Item
  57. {
  58. Rectangle
  59. {
  60. anchors.left: parent.left
  61. id: pic
  62. radius: 100
  63. height: 15; width: 15; color: "red"
  64. }
  65.  
  66. Text
  67. {
  68. anchors.left: pic.right
  69. anchors.leftMargin: 10
  70. text: styleData.value
  71. }
  72. }
  73. }
  74. CC.TableViewColumn
  75. {
  76. role: "bbb"
  77. title: "BBB"
  78. width: 100
  79. }
  80.  
  81. model: ListModel
  82. {
  83. id: mymodel
  84. ListElement
  85. {
  86. aaa : "Banana1"
  87. bbb : "Apple1"
  88. }
  89. ListElement
  90. {
  91. aaa : "Banana2"
  92. bbb : "Apple2"
  93. }
  94. }
  95. }
  96.  
  97. }
To copy to clipboard, switch view to plain text mode