PDA

View Full Version : How Could I promote Qt's Drawing performance?



joeshow
10th September 2007, 08:59
I use Qt3,
I found that when I draw text on a bid widget(full screen),the performance is so bad,
drawing text consume more CPU time than drawing line,polygon etc.
Anybody knows why?
Any suggestion is appreciated.

Thanks,

marcel
10th September 2007, 09:45
Try drawing the text as paths. Add the text to a painter path and draw that path instead.
Maybe it is drawing text that hard because of glyph complexity. Are you drawing a lot of text?

wysota
10th September 2007, 11:18
@marcel: He's using Qt3. There are no painter paths there.

@joeshow: Could we see the code of the paint event for the widget?

joeshow
11th September 2007, 05:24
@wysota: Because my project is somewhat big,so I can't list code clearly.

let me interpret my work:
I take a big widget(inherit from QWidget,full screen) as my canvas,
I draw a lot of object(maybe 400~1000) on it. Every object is composed of multi-lines text(1-6lines),but every line is not more than 20 char.
I redraw all the object every one second, I found that redrawing is much expensive while redrawing polylines( more than ten thousand points) are much springy.
Maybe draw text is much complex than polylines?

My English is poor, so I don't know if I have make myself clear,
But I'm really looking forword to you smart guys's instruction.
Best wishes,

wysota
11th September 2007, 09:14
Did you try using the QCanvas approach instead of painting on the widget directly? Also, have you tried optimizing your paint event in any way, for example by redrawing only those parts of the widget that actually changed?

Raccoon29
11th September 2007, 19:04
Maybe draw text is much complex than polylines?

In the past, also using different developing environments, I've seen that very often texts are much more expensive to draw than the polygons, since text has to intermediate with font operations (and font create operations) that are astoundingly heavy jobs.

Greetings