PDA

View Full Version : QGraphicsScene: evolution of sceneRect



Pieter from Belgium
10th November 2006, 13:12
For the QGraphicsScene::sceneRect, there are two possible evolutions:
- either you do not set the sceneRect explicitly, and it will grow as needed, in order to contain all items, but it never shrinks
- or you set the sceneRect explicitly, and it does no longer evolve as items are added/moved

What I need is that it grows automatically, but also shrinks automatically.
Or as a workaround, I would like to set it explicitly to the current boundingrectangle, without stopping future automatic grows...

Can I realize this?

jpn
10th November 2006, 13:33
You could make use of QGraphicsScene::itemsBoundingRect() and set the scene rect manually on certain occasions. Just make sure you don't call it too intensively, it might turn out to be slow on large scenes..

Pieter from Belgium
10th November 2006, 15:11
Yes, but from then on, automatic growing does no longer occur. (Why is that? Why is no option offered have (explicit or automatic) it shrink while keeping automatic growing?)

Your solution can help me, but then I need to do a lot of administration throughout my application (in order to avoid the application to become slow).