Performance trouble in Graphics View
Hi again,
I'm about to finish my project but I'm currently suffering from the performance. My cursor barely moves(very slow) on the scene. I want you to let me know what possible problem that I'm facing now. Any little idea can be significantly change the performance so please share.
I have number of graphics item inside other graphics item which are all inside the scene and view as usual. I mostly reimplemented boundingRect() and shape() methods together to increase performance when necessary.
If you can't figure out what's I'm saying above, please let me know again.
Cheers, Zeck.
Re: Performance trouble in Graphics View
Please provide more information - what optimizations you already enabled, what items are we talking about, what are their shapes, how many of them are there, etc.
Re: Performance trouble in Graphics View
Sure,
think you have a graphicsitems which resides in a graphics item group. they are all in scene and view.
Now, I reimplement shape() in addition to boundingRect() in order to optimize mouse operations. I already reimplemented boundingRect() in the item group, scene and view as well as i'm supposed to do.
My graphics item are movable. I did drag-drop issue by using itemChange(). I mean when position changes by the mouse, itemChange() method deals with the necessary things( i.e. changing core data) in itself. I suspect there should be something like recursion between itemChange() and paint(). I'm now looking for it.
By the way shapes are polygons that excellently covers around items.
Re: Performance trouble in Graphics View
What's the exact implementation of boundingRect() and shape()? Do you cache items? What's the bottle-neck according to the profiler?
Re: Performance trouble in Graphics View
I'm not allowed to provide code. Sorry for this first of all.
As I said before, in shape() I return a polygon which exactly covers around my item. In boundingRect() I just return a QRect with arbitrary sizes like;
Code:
return new QRect(-1000,
-1000,
2000,
2000);
Re: Performance trouble in Graphics View
Cache as much data as possible. Find the bottleneck using a profiler and eliminate it.
Re: Performance trouble in Graphics View
Hi,
Can you explain a bit more about caching if you don't mind ?.
Re: Performance trouble in Graphics View
Cache the data - don't create instances of QRectF and QPainterPath on every call to boundingRect() and shape(). Also cache the items. And please use a profiler instead of just guessing.
Re: Performance trouble in Graphics View
Have you tried to use OpenGL as the viewport of your QGraphicsView?
It may increase performance.
It is so easy as :