Important: Please read the Qt Code of Conduct -

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 Image

    Please Help Me To solve this problem

    Thanks in Advance

  • Lifetime Qt Champion

    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

    since that is vector based so very easy to move/resize etc any shapes
    Like this exmaple

Log in to reply