View Full Version : partial repaint

18th August 2009, 22:20
I override the paint() method of a QGraphicsWidget subclass with a background color and some text label in the middle. For every second I use a timer to change the background color but keep the same text, or keep the same bg color but change the text. Is there a way for me to do this without having to repaint both of the components, i.e. only text or background color but not both? I'm using QtEmbedded 4.5.

I guess one way would be having 2 separate widgets but since their space overlap each other, it's just cleaner to use one single widget.

All suggestions are appreciated.

18th August 2009, 23:08
Well, basically you do a composition of two layers: Background and text. You can of course keep the upper layer in a pixmap with alpha channel. But I doubt that the compositing of the final image from that second layer will be faster than the font rendering. Font rendering is heavily optimized on modern windowing systems. Also if you use a single background color, filling a rect will be very fast compared to blitting a cache image.

19th August 2009, 00:33
hmm, first I thought by achieving partial repaint would help the performance. But I just found out that if my paint() function is empty, and whenever the timer expires, I would call QGraphicsItem::update(boundingRect()); which practically would have nothing to repaint for that area. And it still takes almost 10% of the CPU. Any idea why it's acting like that?