PDA

View Full Version : how to bypass repainting a containing widget?



RolandHughes
22nd January 2014, 21:27
Should be simple enough, but suffering from old-timer's disease it appears....

Have a widget which paints a background graphic. Widget is derived from QGroupBox but shouldn't matter.

Other widgets are placed inside. One of these widgets happens to be another widget which gets a wavy line drawn in it based on input data. For some reason, every time a point or piece of line gets drawn in that widget the background paint for entire widget is getting called. It shouldn't be because there is nothing for it to do.

Suggestions?

Thanks

Roland

anda_skoa
23rd January 2014, 08:34
Can you check if the paintEvent on the container is only for the area of the child or for the whole container?

My guess is that it is just for the area of the child, basically the automatic background painting for the child. In which case some flags like widget attributes Qt::WA_NoSystemBackground or Qt::WA_OpaquePaintEvent or Qt::WA_TranslucentBackground might help.

Cheers,
_

RolandHughes
30th January 2014, 21:10
Thanks for the guess anda,

No, it's not a child. It's a compound widget. There is a groupbox containing an image which provides the background image for the entire group area. On "top" of that are many other widgets. The particular widget causing the problem is drawing a wave line on its own background. I didn't write this code so I need to go digging in some examples because I think this one is simply wrong. Previous developer is calling update() passing the QRect() containing the new line segment. Each one of those is propagating out to case the background paint even though that piece of the background is completely hidden. One doesn't know about the other so "ignoring" the event would be a bit involved.

Thanks again for trying. Always difficult to answer things on here without complete picture.

Roland

anda_skoa
31st January 2014, 10:42
No, it's not a child. It's a compound widget.

Misunderstanding :)

What I was asking is: if you check the paint event received by the parent/conainer (the compound widget), does its update rect information indicate that the area of that particular child is to be repainted or is repainting of the whole container being requested?

Cheers,
_