[Qt-interest] Restoring default widget brush

Denis Akhmetzyanov dakhmetzyanov at smartlabs.tv
Fri Apr 9 11:23:28 CEST 2010


I've used another approach in similar cases:

class MyWidget : public QWidget {
public:
     MyWidget() {
          m_defaultWidgetPalette = palette();
     }

     void restorePalette() {
          setPalette(m_defaultWidgetPalette);
     }

private:
     QPalette m_defaultWidgetPalette;
};

2010/4/9 Denis Akhmetzyanov <dakhmetzyanov at smartlabs.tv>

> But the application's palette and the current widget's palette may be
> different (or become different in the future). Some other widget could
> change application's palette or you could change your widget's palette
> during further development. For example the note from
> QApplication::setPalette() doc:
>
> *Warning: Do not use this function in conjunction with Qt Style Sheets<http://stylesheet.html>.
> When using style sheets, the palette of a widget can be customized using the
> "color", "background-color", "selection-color", "selection-background-color"
> and "alternate-background-color".*
> *
> *
> *So it seems to me a fragile decision which can leads to trouble in the
> future.
> *
>
> 2010/4/8 Nikos Chantziaras <realnc at arcor.de>
>
> On 04/08/2010 09:15 PM, J-P Nurmi wrote:
>> > On Thu, Apr 8, 2010 at 8:54 PM, Nikos Chantziaras<realnc at arcor.de>
>>  wrote:
>> >> That should work.  But this shouldn't be needed at all.  There has to
>> be
>> >> a way to reset the brush to its default without doing backups.
>> >>
>> >
>> > QPalette::QPalette() constructs a palette object that uses the
>> > application's default palette.
>>
>> Thanks!  Somehow I missed that one.
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
>
> --
> Best regards,
> Denis Akhmetzyanov
>



-- 
Best regards,
Denis Akhmetzyanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100409/1774b0fa/attachment.html 


More information about the Qt-interest-old mailing list