Optimizing redrawing in the scene
Hi,
I have created a lot of items in the scene. I also have a rectangle(QGraphicsREctItem) moving with the cursor. Whenever the rectangle moves on the items, memory usage reaches 100%, and it moves slowly, when I move the rectangle from items, it works fine. It looks as if the items were redrawn everytime the rect changes pos and intersects with them. I need the same performence while moving the rect on that items as when I have only a cursor(nothing is redrawn then). How to do that? Maybe I should create that (zooming) directly on the viewport and that map view -> scene coordinates/
Any ideas appreciated.
Thanks.
Maverick
Re: Optimizing redrawing in the scene
The performance loss is caused by the fact that the item index needs to be rebuilt. You might want to disable indexing while you move items, if you don't need collision detection. See QGraphicsScene::setItemIndexMethod() and the respective property.
Re: Optimizing redrawing in the scene
I already have this:
in the constructor of my scene.
Re: Optimizing redrawing in the scene
In that case try avoiding collision detection and cache items. Andreas has recently posted an article about it @ labs.
Edit: Or lose the rect...
Re: Optimizing redrawing in the scene
ok. will do so and reply later.
I suppose I need to pop in to lab.trolltech sometimes.