Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the title bar of a Qt app through Qt stylesheet?

I'm able to customize the controls of a Qt app in a Qt stylesheet. However, I couldn't find a way to customize the title bar. I found some solutions but that requires modifying the code of the app itself. Is there anyway you could customize it using just the Qt stylesheet?

like image 691
Owen Avatar asked Dec 22 '10 09:12

Owen


2 Answers

Title bar isn't a part of your application or Qt and it cannot be configured with stylesheet. Title bar is provided by Window manager. In some WMs there is no title bar at all. Most WMs support customisable themes for window decoration. Usualy you can configure you WM to display specific window with specific theme.

In Qt only QDockWidget's title bar can be configured by stylesheet.

P.S. Some applications disable decoration from window manager and draw title bar itself (example Chromium).

like image 116
graphite Avatar answered Sep 18 '22 11:09

graphite


Qt has no control over the appearance of the title bar and border of an application. This is the realm of the Window Manager (WM) in use. Qt can ask the WM to turn it off or only display certain buttons, but that's the extent of it.

The standard procedure for a customized title bar is to remove it, and then create and style your own take on the title bar in its place. To anyone watching, please note that this isn't as cool as you think it is. Some people like to customize their titlebar, most people like it when their application blends in with the rest of their operating environment (which it won't when you're done with it).

Short answer: there's no way to do this to an existing application using Qt stylesheets without changing the application's source code.

like image 45
OliJG Avatar answered Sep 21 '22 11:09

OliJG