[Qt-interest] QApplication::setPalette loses some colors
Constantin Makshin
cmakshin at gmail.com
Wed Aug 31 16:02:16 CEST 2011
QApplication::setPalette() function documentation (http://doc.qt.nokia.com/4.7/qapplication.html#setPalette) says "The palette may be changed according to the current GUI style in QStyle::polish()." which "Changes the palette according to style specific requirements for color palettes (if any).".
So Qt is likely to work as intended and your problem may be caused by the style you use.
On Wednesday, August 31, 2011 05:46:28 PM Schimkowitsch Robert wrote:
> I have an issue that setting the global application palette using
> QApplication::setPalette does not work for all colors.
>
> I prepare a QPalette with the colors I want to use in my application.
>
> The I call the following:
>
> qDebug() << "Old Window color"
> << QApplication::palette().color(QPalette::Window);
> qDebug() << "New Window color"
> << pal.color(QPalette::Window);
> qDebug() << "Old AlternateBase color"
> << QApplication::palette().color(QPalette::AlternateBase);
> qDebug() << "New AlternateBase color"
> << pal.color(QPalette::AlternateBase);
>
> QApplication::setPalette(pal);
>
> qDebug() << "after setPalette"
> << QApplication::palette().color(QPalette::Window);
> qDebug() << "after setPalette"
> << QApplication::palette().color(QPalette::AlternateBase);
>
> which outputs:
>
> Old Window color QColor(ARGB 1, 0.831373, 0.815686, 0.784314)
> New Window color QColor(ARGB 1, 0.196078, 0.196078, 0.196078)
> Old AlternateBase color QColor(ARGB 1, 0.909087, 0.909087, 0.909087)
> New AlternateBase color QColor(ARGB 1, 0.392157, 0.392157, 0.392157)
> after setPalette QColor(ARGB 1, 0.196078, 0.196078, 0.196078)
> after setPalette QColor(ARGB 1, 0, 0, 0)
>
> As you can see, the "Window" color role is OK, whereas the AlternateBase
> is now black, not the color I specified.
>
> Why is that?
>
> Kind regards
>
> Robert Schimkowitsch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110831/adffe74a/attachment.bin
More information about the Qt-interest-old
mailing list