Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to draw Movable and Re-sizable Line On QLabel
Forum Updated to NodeBB v4.3 + New Features

how to draw Movable and Re-sizable Line On QLabel

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 275 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ketan__Patel__0011K Offline
    Ketan__Patel__0011K Offline
    Ketan__Patel__0011
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.html

      since 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

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved