1

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

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Bb Gg
  • 23
  • 6

1 Answers1

2

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.

codinglikejesus
  • 60
  • 1
  • 1
  • 9
  • thank you so much. as you have said by using myview->scale((qreal)new_width/ (qreal)old_width, (qreal)new_height / (qreal)old_height); i am able to scale whole content. – Bb Gg Dec 06 '18 at 13:30