PDA

View Full Version : Performance trouble in Graphics View



zgulser
10th September 2009, 16:42
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.

wysota
10th September 2009, 17:20
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.

zgulser
10th September 2009, 18:02
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.

wysota
10th September 2009, 20:43
What's the exact implementation of boundingRect() and shape()? Do you cache items? What's the bottle-neck according to the profiler?

zgulser
11th September 2009, 09:52
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;


return new QRect(-1000, -1000, 2000, 2000);

wysota
13th September 2009, 15:53
Cache as much data as possible. Find the bottleneck using a profiler and eliminate it.

zgulser
14th September 2009, 14:32
Hi,

Can you explain a bit more about caching if you don't mind ?.

wysota
14th September 2009, 17:52
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.

scascio
14th September 2009, 22:11
Have you tried to use OpenGL as the viewport of your QGraphicsView?
It may increase performance.

It is so easy as :

setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));