PDA

View Full Version : Low Performance in QGraphicsView



fruzzo
18th October 2012, 17:40
Hi,
I'm developing something like a Gantt diagram (see attached image):
8318

I have a QTimer that every 100msec update my time cursor (the black vertical line) in the diagram and other widgets but I noticed that the effective update rate is more than 100ms.

First of all, I known that the QTimer isn't so perfect in timing however, without my time cursor update, other widgets are updated about every 110 msec (but this is another story :)).

Adding my time cursor update the performance is degraded so checking my code I found that the QGraphicsView::paintEvent execution time is about 60-70msec.

Cursor time is drawed in MyGraphicsScene::drawForeground such as the dotted horizontal line are dreawed in MyGraphicsScene::drawBackground.

As suggested in other posts:

Horizontal green rectangle are items having cache enabled ( setChacheMode (ItemCoordinateCache) ).
I can't set view interactive property to false because I need my scene to be clickable.
I'm using Qt 4.5.0 so I can't set ItemHasNoContents flag
I haven't explicit set the OpenGL engine so I suppose that I'm using the raster one


How can I increase my perferomace reducing the QGraphicsView::paintEvent execution time so that I've an update rate near to 100msec?

Santosh Reddy
19th October 2012, 07:36
How can I increase my perferomace reducing the QGraphicsView:aintEvent execution time so that I've an update rate near to 100msec?
Think again, is it really required to update at 100ms rate?

Can't you update every 1000 ms with 10 samples?

ChrisW67
19th October 2012, 08:04
... without my time cursor update, other widgets are updated about every 110 msec (but this is another story ).
No, I think that is the story. If the scene take 110 milliseconds to update and paint then that's the fastest it will update unless you do something about that. Adding the single line cursor is clearly not an impost in itself, it just cannot be drawn every 100msecs because the processor will still be drawing the bars when the timer notionally fires.

I cannot imagine the every bar in the scene is actually changing every tenth of a second. Are you changing things that don't need to be changed and invalidating the caching?