Hi. I want to make a working MouseArea on ListElements. If I just add MouseArea to an Item, then every ListElement would do the same thing. How do i make a working menu of these two (I mean making them do different things on click). Let's say Name1 should change it's name onclick, and Name2 should close app.
Qt Code:
  1. ListView {
  2. id: listView2
  3. x: 20
  4. y: 430
  5. orientation: ListView.Horizontal
  6. anchors.rightMargin: 20
  7. anchors.leftMargin: 20
  8. anchors.bottomMargin: 10
  9. anchors.top: listView1.bottom
  10. anchors.right: parent.right
  11. anchors.bottom: parent.bottom
  12. anchors.left: parent.left
  13. anchors.topMargin: 50
  14. model: ListModel {
  15.  
  16. ListElement {
  17. name: "Name1"
  18. sourcepath: "icon1.png"
  19. }
  20. ListElement {
  21. name: "Name2"
  22. sourcepath: "icon2.png"
  23. }
  24. }
  25. delegate: Item {
  26. x: 5
  27. width: 150
  28. height: 40
  29. Row {
  30. id: row2
  31. spacing: 0
  32. Image {
  33. width: 40
  34. height: 40
  35. source: sourcepath
  36. }
  37. Text {
  38. text: name
  39. font.bold: true
  40. anchors.verticalCenter: parent.verticalCenter
  41. }
  42. }
  43. }
  44. }
To copy to clipboard, switch view to plain text mode 
Also how do I add smth like a button, that would add listelement with choosen values.