qtqt4stylesheetqtoolbarqmenubar

How to force QMenuBar to have the same background color as QToolBar


My menu bar is placed inside my toolbar :) And I wan't both of them to have the same background color. In some color themes menubar background is different then in toolbars (lighter). How do I sync them and at the same time maintain current theme colors.

Can I force QMenuBar not to draw background ?

I tried to use stylesheets with background-color:.. but submenus in menu bar lose borders and there is now hover effect.

Thanks for help :)


Solution

  • You can try something like this:

    QPalette palette = menuBar->palette();
    palette.setColor(QPalette::Button,  toolBar->palette().color(QPalette::Window));
    menuBar->setPalette(palette);
    

    Hope this helps :)