[Qt-interest] Restoring default widget brush

Nikos Chantziaras realnc at arcor.de
Thu Apr 8 14:10:40 CEST 2010


Suppose I change the brush of a widget like this:

   QPalette p(this->widget()->palette());
   p.setBrush(QPalette::Base, pixmap);
   this->widget()->setPalette(p);

(I *think* this is the correct way of using a pixmap to change the 
background of a widget to an image.)

How do I restore the widget background back to its default?  The below 
segfaults:

   QPalette p(this->widget()->palette());
   p.setBrush(QPalette::Base, QBrush());
   this->widget()->setPalette(p);  // <-- crashes



More information about the Qt-interest-old mailing list