how to draw Movable and Re-sizable Line On QLabel
-
Hello Friends
I Am Trying To Draw Movable And Re-sizable Line using Mouse On Over The QLabel ImagePlease Help Me To solve this problem
Thanks in Advance
-
Hi
So what do you have so far ?You will need to overwrite
mousePressEvent, mouseMoveEvent and mouseReleaseEvent
to draw a line.You then need to store the points that makes up the line.
Do you plan to have more than one line at same time ?
if yes, you need to keep a list of pair of points pr line.Then to be able to move it , you need to write a function that can
find a point on a line so when user click it you can check if hit.to be able to resize it, you can use the
mousePressEvent, mouseMoveEvent and mouseReleaseEvent
again to allow user to click at end points and drag.Looking at your other post about zooming and drawing shapes on top of image, i was wondering if
you been better off using
https://doc.qt.io/qt-5/graphicsview.htmlsince that is vector based so very easy to move/resize etc any shapes
Like this exmaple
https://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html