[Qt-interest] Restoring default widget brush

David Boosalis david.boosalis at gmail.com
Thu Apr 8 21:55:28 CEST 2010


I use
painter->save()
...
painter->restore

Maybe it will suit your needs as well.

-David




On Thu, Apr 8, 2010 at 5:10 AM, Nikos Chantziaras <realnc at arcor.de> wrote:

> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100408/be4a96c5/attachment.html 


More information about the Qt-interest-old mailing list