user666491
user666491

Reputation:

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 :)

Upvotes: 1

Views: 3985

Answers (1)

Sebastian Dusza
Sebastian Dusza

Reputation: 2528

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 :)

Upvotes: 5

Related Questions