Animating many items in a QGraphicsScene
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!
Re: Animating many items in a QGraphicsScene
Re: Animating many items in a QGraphicsScene
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...
Re: Animating many items in a QGraphicsScene
Quote:
Originally Posted by
Luc4
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.
Quote:
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.
Re: Animating many items in a QGraphicsScene
I can understand... So there is no way to improve the performance? Thanks for your answer!
Re: Animating many items in a QGraphicsScene
Quote:
Originally Posted by
Luc4
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.
Re: Animating many items in a QGraphicsScene
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