Search code examples
c++qtqt5qgraphicssceneqgraphicsitem

Resize QGraphicsScene with all QGraphicsItems in it


I have overrided QGraphicsScene with couple of QGraphicsItems in it. I plan to make this scene dynamically resizable with mouse movements. When qgraphicsscene size changes, sizes and positions of items should also change accordingly so that relative position of items mapped to scene always stay same. How can I manage this ?

Below image explains what I aimed to do: Red area represents QGraphicsScene and shapes represent items in it

resized qgraphicsScene with items in it


Solution

  • If you just want to implement a "zoom" functionality, you could call QGraphicsView::Scale. If you want to bind this to a mouse event, you'll need to create your own inherited view and implement the functionality in a event handler.