I can put a bezier curve on a MouseArea on mouseclick. I can even drag and drop it. But how can I change the color of the curve while dragging it? My code:

Qt Code:
  1. Item {
  2. Path {
  3. id: mycurve
  4. startX: -132; startY: -12
  5. PathCurve { x: -138; y: -14 }
  6. PathCurve { x: -140; y: -20 }
  7. PathCurve { x: -146; y: -22 }
  8. }
  9. Rectangle {
  10. id: rect
  11. width: 2
  12. height: 2
  13. color: "black"
  14. border.color: "black"
  15.  
  16.  
  17. MouseArea {
  18. anchors.fill: parent
  19. acceptedButtons: Qt.LeftButton | Qt.RightButton
  20. onPressed: {mycurve.color = "red";}//what should I do here?
  21. onReleased: {mycurve.color = "black";}//what should I do here?
  22. onPositionChanged: {
  23. if (mouse.buttons & Qt.LeftButton) {
  24. mycurve.x -= (x - mouse.x); mycurve.y = (y - mouse.y); ;
  25. }
  26.  
  27. }
  28. }
  29. PathView {
  30. id: pathView1;
  31. x: 158
  32. width: 708
  33. model: 300;
  34. path: mycurve
  35. delegate: Rectangle {
  36. id: dot;
  37. width: 1; height: 1;
  38. color: "black"
  39. ColorAnimation on color { to: "red"; duration: 0 }//my own attempt
  40. }
  41. }
  42. }
  43. }
To copy to clipboard, switch view to plain text mode