PDA

View Full Version : QGraphicView Optimizing cpu



fkili
27th September 2012, 11:32
hello

I have edit a Qt application using QGraphicsView / QGraphicScene and it's consume a lot of cpu (60%).

my classes are a custom QGraphicsView / QGraphicScene and Reimplemented
QGraphicsView::drawforeground(QPainter* ptPainter, const QRectF& tRectToDraw) and
QGraphicsView::drawbackground(QPainter* ptPainter, const QRectF& tRectToDraw) used for drawing some statics items.

and i think thats methods causes the big consume of cpu.
my question is how can i optimise my application and reducing cpu consume.

thanx in advance.:)

wysota
27th September 2012, 12:20
Without seeing any actual code it is hard to suggest anything.

fkili
27th September 2012, 12:56
this is the sources of qgraphicsvew and qgraphicscene attached.
8260826182628263

wysota
27th September 2012, 13:05
First of all I don't think you should be calling QGraphicsView::drawForeground() from within drawBackground(). Second of all try reducing the amount of calculations done in drawBackground() and certainly do not create any items in drawForeground(). Apart from that, since you are caching the background, drawBackground() should not be very expensive as it is, unless you are changing the scene size (or zooming in and out) frequently. Then caching the background will slow down your app instead of speeding it up. In that case try removing the gradient from your background and see if it helps anything.

fkili
27th September 2012, 14:02
thanx wysota