Hi Everyone,

I am a newbie to QML and I wanted to select some rectangle ROI's in an Image. I am getting co-ordinates during mouse press and release event. Now, I need to start drawing a rectangle during mouse press event and end the rectangle during mouse release event. I have done this using Qt Widgets application, but I was thinking to implement the same in QML. Can someone guide me to implement this.

Here's my code

Qt Code:
  1. import QtQuick 1.1
  2.  
  3. Rectangle {
  4. id:imageRect
  5. width: 300
  6. height: 300
  7.  
  8. property int pressX
  9. property int pressY
  10. property int releaseX
  11. property int releaseY
  12.  
  13.  
  14. Image{
  15. id:imagetoshow
  16. source:"file:///C://Users//Jakr13//Desktop//testimage.bmp"
  17. }
  18.  
  19. MouseArea {
  20. id:roiRectArea
  21. anchors.fill: parent
  22.  
  23. onPressed: {
  24. pressX = mouse.x
  25. pressY = mouse.y
  26. console.log("Pressed Co-ordinates",pressX,pressY);
  27. }
  28.  
  29. onReleased: {
  30. releaseX = mouse.x
  31. releaseY = mouse.y
  32. console.log("Released Co-ordinates",releaseX,releaseY);
  33. }
  34. }
  35. }
To copy to clipboard, switch view to plain text mode 

Please feel free to point if there is anything wrong with my code or the way I am implementing is completely wrong.

Thanks in advance

Jakr13