Nominate our 2022 Qt Champions!

A working example of a selection rectangle with grab handles, in a QGraphicsScene

  • I can muddle through this myself, so the best answer would be working code I can crib from. I need to avoid the tedium of discovering what details work and which ones don’t.

    Many art programs, such as Gimp, allow you to draw a temporary rectangle, then fine-tune it with grab handles. A grab handle on each side lets you pull the side; a grab handle in each corner lets you pull two sides, etc.

    Does anyone have an example of a working application, in any language, with the rest of this system? Beyond the “scene.addRect(x, y, w, h, _pens[color])” part?

  • more explanation needed. :)

  • Open up MSPaint.exe (or the equivalent art program on your platform) click on the Select tool, and drag a rectangle on your image.

    The rectangle has little "grab handles" in each corner, and in the middle of each line. Hovering over a grab handle turns your mouse pointer into an appropriate icon, and dragging that drag handle adjusts its lines.

    I know how to research and implement each detail of such a feature - marking a rectangle with drag handles, changing the mouse pointer, capturing the mouse, etc.

    I'm asking if anyone has already implemented "drag handles on floating rectangle, to select something in an image", and if there's already source code out there (in any language) that I can crib from.

  • I understand now :)
    You want to select a set of items in a GraphicsView by pressing and moving the mouse, simultaneously.
    I think the solution is like when you draw a line by pressing/moving the mouse. You can see the diagramscene example, to get an idea.

    In the other hand I know a libre soft that uses this trick.
    You can get its source here [Umbrello UML Modeller]

    Good luck !

Log in to reply