PDA

View Full Version : update of the child widget causes paintEvent() of the parent widget to be called



starch
11th March 2011, 08:16
Dear all,

I have a full screen main window P (parent widget) showing an image using paintEvent(). A child widget C is attached to this main window and calling its own update() periodically. It seems that once the update() of C is called, the paintEvent() of P gets called as well, which consumes a lot of CPU (on Ubuntu X11).

Because C may have (semi-) transparent colors, I cannot set Qt::WA_OpaquePaintEvent attribute for it. Is there any other way to prevent calling P's paintEvent() or to reduce the CPU consumption substantially?

Thanks in advance for any suggestions.

wysota
11th March 2011, 20:34
Since your C has a semi-transparent background, the parent has to be painted first prior to painting the child. In some cases Qt will take the background from its backing store, in some it will call the paint event of the parent. If you optimize the paint event of the parent and only paint the part which is requested, the overhead should be small.