PDA

View Full Version : Animating many items in a QGraphicsScene



Luc4
25th April 2010, 13:55
Hi! I created a QGraphicsView where I have many objects. These objects have to move in the scene when a button is clicked. The fact is that the major part of these items is not visible and won't be visible even when the animation occurs.

It seems to me that the view redraws everything even if it is not visible. Is it possible to tell the view to redraw only in case the items are inside the view? Or maybe I have to do this myself by computing somehow which items will be visible or not during the animation and make only them move?

I need this as the device that will show the animations is very slow, so any reduction of computation would be very useful.
Thanks!

Diph
25th April 2010, 14:09
Maybe this helps: http://doc.qt.nokia.com/qt-maemo-4.6/qgraphicsview.html#ViewportUpdateMode-enum

Luc4
25th April 2010, 14:49
I already read this. As far as I can see this would be the best: QGraphicsView::MinimalViewportUpdate. Unfortunately it seems this is the default mode, thus it is already applied...

wysota
25th April 2010, 19:50
It seems to me that the view redraws everything even if it is not visible.
No, the view only redraws the items that are at least partially visible.


Or maybe I have to do this myself by computing somehow which items will be visible or not during the animation and make only them move?
Your only job is to return proper bounding rectangles for your items.

Luc4
26th April 2010, 21:07
I can understand... So there is no way to improve the performance? Thanks for your answer!

wysota
4th May 2010, 22:24
So there is no way to improve the performance?
I didn't say that. First you have to find the bottle neck before you start improving things randomly.

ahmedb
5th May 2010, 06:55
Show us the code of the GraphicsItem you use, so we can help you improving the performance. Maybe you didn't calculate the bounding box acuratley, the fact that made your scene performance bad.

Best wishes