Resize a QGraphicsItem into a QGraphicsScene
candidinho last edited by
Can I resize with the mouse a QGraphicsPoligonItem into a QGraphicsView/QGraphicsScene?
I don't know the way to do it.
What functions do i have to reimplement?
ZapB last edited by
Here's one way to do it:
Make your item selectable (setFlag())
If the item is selected, have your custom item class paint a resize handle in each corner and edge
In your custom item class, override the mousePress(), mouseMove(), and mouseRelease() virtual functions.
In the mousePress() function add code to check if the mouse press is over one of the handles. If it is set a flag that says you are in "resize mode".
In the mouseMove() function, if you are in "resize mode" then resize (and maybe reposition) your item as determined by the moved amount. Remember to call prepareGeometryChange() to ensure the item gets repainted.
In the mouseRelease() function flag that you are no longer in "resize mode".