PDA

View Full Version : How to use system colors in QToolBar?



isamert
20th August 2014, 15:36
For example, in ubuntu gtk apps has a black toolbar. I'm trying to create a qt app, but QToolbar doesnt use system color(in this case, black). So how can I make QToolBar to use system color? If this is impossible, how can I get the title bar's color(to make toolbars background color)? And I found something for mac to make compatible titlebar and toolbars: "setUnifiedTitleAndToolBarOnMac(true)". Is there a equivalent thing for ubuntu/unity/gtk desktops?

d_stranz
20th August 2014, 18:52
QToolBar is derived from QWidget, so you should be able to retrieve the QPalette, set the QPalette::Window role to the color you want, then set the palette back on the toolbar. Alternatively, you could apply a style sheet to the toolbar.

If you aren't setting the window (background) color, then the widget is using the system color, as given by QApplication::palette(). So if the background isn't black as you expect, it is because the application doesn't think it should be.

isamert
20th August 2014, 20:02
I know I can set backgroundcolor to widget but I want it to use with system colors. It seems there is no way to use system colors in toolbars like gtk apps. So, how can I get the title bar's color? Is there any way to do that?

anda_skoa
21st August 2014, 10:32
This could be a style issue.
Maybe your application is not using the GTK integration style.

Cheers,
_