[Development] Qt5.2 application palette

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Thu Dec 5 16:27:29 CET 2013


On 05 Dec 2013, at 15:31, Martin Koller <kollix at aon.at> wrote:

> I'm at ec03058fa5b84b4570a2158bf2179f7ba4d83b99 and I see something I can not explain:
> 
>  QApplication app(argc, argv);
> 
>  cerr << "style:" << qPrintable(QApplication::style()->objectName()) << std::endl;
> 
>  QPalette pal = QApplication::palette();
>  cerr << "dark:" << qPrintable(pal.brush(QPalette::Dark).color().name()) << endl;
> 
> 
> this code tells me the style I use is "fusion" and the "dark" value is #000000
> 
> However using this code
> 
>  extern QPalette qt_fusionPalette();
> 
>  QPalette fpal = qt_fusionPalette();
> 
> tells me that dark is #9f9d9a
> 
> 
> I was thinking the style defines the default palette.
> 
> When compiling against Qt 4.8.5 and using -style plastique I get "dark" as #6a6563
> 
> I'm struggling with this as "dark" is the background color of a QMdiArea and in Qt4 it is really gray
> as documented, but in Qt5 it's black.


It’s not that simple. The fusionPalette is actually only used to populate the QStyle::standardPalette() and is rarely used by Qt itself unless you _explicitly_ apply it to your QApplication. Depending on the platform you are on, the application palette should automatically be derived from your desktop settings such as KDE or Windows colour schemes and fusion will make use of those instead.I suspect you have a broken configuration file or perhaps Qt5 is incorrectly parsing your system settings. It is not really possible to know what is wrong without more information about your platform or setup.

Regards,
Jens




More information about the Development mailing list