Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Menubar uses colors not defined in QApplication::palette()
Forum Updated to NodeBB v4.3 + New Features

Menubar uses colors not defined in QApplication::palette()

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        Thanks, that seems to be the point I missed!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved