Passing x,y pixel coordinates to QML

  • I am developing an app that has etch-a-sketch like functionality. I need to pass (x, y) pixel coordinates to QML so that lines can be drawn between the points.

    I initially thought that I would create an array in QML to store the pixel coordinates. However, I understand that dynamic array functionality is limited in QML.

    Any suggestions as to an efficient data structure to dynamically store (x, y) coordinates so that lines can be drawn in QML?

    Thank you.


  • use mouse.x and mouse.y.

  • @Bhushan99


    I have no issues obtaining the current (x, y) pixel coordinates. However, I have not found a suitable data structure to dynamically store 1000+ coordinates so that I can efficiently draw lines between the pixel coordinates in a for loop.


  • @Hoyt what about using C++ backend to store the list of points and then QML using that model list to do the drawing?

  • Pablo,

    Thank you for the suggestion. I will try the model list and let you know how it goes. Thanks again.


Log in to reply