PDA

View Full Version : how to get notified when the displayed region in a scene changes



momesana
27th October 2008, 18:53
Hi,
I want to get notified once the area displayed in a QGraphicsView changes. That is to say, once the area is zoomed in, zoomed out, scrolled, or whateva else that may make items that were not visible before visible in the view. The reason for this is that I want the items only to do some operations when they are visible in the view. And once they are not visible anymore (for example if we scroll to another region of the scene) they should free some resources etc. so that memory usage is minimized. What is the best way to do that?

Thanks in advance

momesana
28th October 2008, 12:14
Really no Idea what I could do in that situation? Maybe I didn't appropriately describe the problem. I am trying to find a way to detect when an item on a QGraphicsScene becomes or stops being "visualized" by a QGraphicsView. That is because the items each contain a QImage that may have a large size and I want to free the resuorces once the item is not visualized by any view any longer and initialize it again whenever it becomes visualized by a view. I thought if I was notfied by a signal or an event once the area visualized by a view changes I could translate the view's rect to scene coordinates and find the items who'se boundingRect intersects with that view. The only problem is I don't know how to get notfied about the change I described above. Can you think of any workaround or do you have any other suggestions that may help me here?