Where do I write the mouseclick event and what would be the way to extract mouse clicked row data?

I looked in this thread:https://stackoverflow.com/questions/...ick-controls-2

I changed my MouseArea accordingly but it says that row is undefined.

Please help.

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