开发者

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

开发者 https://www.devze.com 2023-03-02 02:58 出处:网络
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 t

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 tri开发者_如何学Goed to use stylesheets with background-color:.. but submenus in menu bar lose borders and there is now hover effect.

Thanks for help :)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消