[Qt-interest] Restoring default widget brush
Denis Akhmetzyanov
dakhmetzyanov at smartlabs.tv
Thu Apr 8 14:21:20 CEST 2010
Hi,
You could save old brush before change:
QPalette p(this->widget()->palette());
QBrush oldBrush = p.brush(QPalette::Base);
p.setBrush(QPalette::Base, pixmap);
this->widget()->setPalette(p);
// do something
...
// restore brush
p.setBrush(QPalette::Base, oldBrush);
this->widget()->setPalette(p);
2010/4/8 Nikos Chantziaras <realnc at arcor.de>
> 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
>
--
Best regards,
Denis Akhmetzyanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100408/49b36d8d/attachment.html
More information about the Qt-interest-old
mailing list