[Interest] Draw multiple rectangles in a QGraphicsItem using the mouse

David Carmona david.carmona93 at gmail.com
Tue Oct 20 09:10:01 CEST 2015


Hi Michael,

Thank you for your answer. I'm going to try it and tell you.

Regards
David
Le 20 oct. 2015 08:42, "Michael Sué" <sue at sf.mpg.de> a écrit :

> Hi,
>
> > I would like to create a Graphical User Interface which allows the user
> to draw as many rectangles as he wants on an image using the left button of
> his mouse.
>
> In the mousePressEvent you would create a QGraphicsRectItem, add it to the
> graphics scene and make it "the current one".
>
> In mouseMoveEvent you would change the current rect's edge according to
> the mouse position.
>
> The code in "paint" seems not really necessary as graphics items added to
> the graphics scene know how to draw themselves.
>
> Your image you would draw in the virtual drawBackground method of your
> graphics view.
>
> - Michael.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151020/d8a23b5a/attachment.html>


More information about the Interest mailing list