1

I'm using Qt5.6, I have QWidget graphic objects rendered and when other graphics are rendered in front of others this seems to trigger updates of the graphics under the graphics in front.

This creates overhead, I would like to determine if the graphic behind is completely obscured by the graphic in front and if so, then it should abort the paint event.

I thought this would be automatic and done as part of the internals of Qt, but it seems not.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
SPlatten
  • 5,334
  • 11
  • 57
  • 128
  • Just QWidget derived objects. – SPlatten Aug 15 '16 at 16:28
  • 1) How come you did get to the situation of one widget completely on top of another? 2) Are you sure you're getting an unclipped region in your QPaintEvent argument? – peppe Aug 15 '16 at 16:33
  • My application renders content from an xml file. Some widgets have child widgets that appear over the parents. – SPlatten Aug 15 '16 at 16:44

1 Answers1

1

Each widget's paint event is comes from the widget compositor, once the compositor determines that a widget should be repainted. There's no way to abort it: if the event arrives, it means that the widget must paint, or else you'll get visually undefined results.

By default, widgets can be transparent, and the widget compositor has to paint the entire stack of widgets in back-to-front order to compose them.

Any widget that is not transparent should have the Qt::WA_OpaquePaintEvent attribute set. This will inform the widget compositor that any widgets completely hidden behind the widget don't have to be painted. Ensure that you paint every pixel of your widget!

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313