Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Drawing polygon ROI using mouse with re-sizable handles for vertices



  • I have a project where i need to extract ROI based on polygons. I tried QGraphicsPathItem along with QPainterPath but couldn't achieve the one like shown below in the picture.

    Annotation 2020-05-08 095730.jpg

    Background:

    I already have subclassed QGraphicsItem which i use to paint my bounding boxes and ellipses based on LMB+Drag and they work fine. I already have my custom re-sizable handles also implemented for my QGraphicsItem

    I want to create this polygon ROI exactly as:

    Action1: Clicking first time creates a starting point
    Action2: Selecting another point shows line from the starting point and creates a re-sizable handle at the point
    .
    .
    ActionN: Clicking on starting point again should close the subpath.

    I am not sure how to get this working on my scene. Any ideas or pointers to demo code?


  • Lifetime Qt Champion

    Hi,

    Maybe QGraphicsPathItem can be a starting point.


Log in to reply