Menubar uses colors not defined in QApplication::palette()
-
On Windows 7, the menu bar draws in colors I haven't defined in QApplication::palette().
I am changing all the colors in the palette, yet, the menu bar background is drawn in two different colors.
This is the code I use to set the colors. I don't think I missed anything as major as a menu background (and it does work on XP):
@ QPalette pal = QApplication::palette();
setColorAndBrush(pal, QPalette::Window, QColor(50,50,50)); setColorAndBrush(pal, QPalette::WindowText, Qt::white); setColorAndBrush(pal, QPalette::WindowText, QColor(159,159,159), QPalette::Disabled); setColorAndBrush(pal, QPalette::Base, Qt::black); setColorAndBrush(pal, QPalette::Text, Qt::white); setColorAndBrush(pal, QPalette::AlternateBase, QColor(100,100,100)); setColorAndBrush(pal, QPalette::ToolTipBase, QColor(255, 255, 225)); setColorAndBrush(pal, QPalette::ToolTipText, Qt::black); setColorAndBrush(pal, QPalette::Button, Qt::black); setColorAndBrush(pal, QPalette::ButtonText, Qt::white); setColorAndBrush(pal, QPalette::ButtonText, QColor(159,159,159), QPalette::Disabled); setColorAndBrush(pal, QPalette::BrightText, Qt::white); setColorAndBrush(pal, QPalette::Light, QColor(120,120,120)); setColorAndBrush(pal, QPalette::Midlight, QColor(90,90,90)); setColorAndBrush(pal, QPalette::Mid, QColor(60,60,60)); setColorAndBrush(pal, QPalette::Dark, QColor(30,30,30)); setColorAndBrush(pal, QPalette::Shadow, Qt::black); setColorAndBrush(pal, QPalette::Highlight, QColor(40,40,70)); setColorAndBrush(pal, QPalette::HighlightedText, Qt::white); setColorAndBrush(pal, QPalette::Link, QColor(85,170,255)); setColorAndBrush(pal, QPalette::LinkVisited, QColor(170,100,240)); QApplication::setPalette(pal);@
NOTE: This is an application for an embedded device that is only run on Windows for testing purposes. Hence the rather strange style for a windows application.
Still, even for testing purposes, the menu items should be readable. -
As in the "documentation":http://developer.qt.nokia.com/doc/qt-4.7/qpalette.html:
[quote]
Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows XP, Windows Vista, and the Mac OS X styles.
[/quote]So, this behaviour is to be expected.
Note that while styles are free to ignore the palette, the build-in Qt styles will not ignore style sheets.
-
Thanks, that seems to be the point I missed!