qdockwidget title bar font color

4.8k views Asked by At

How to change the font color of the button text in qtoolbar and title bar text of qdockwidget.

I have tried to change the font color using qt stylesheet color label, but it does not seem to work for qdockwidget::title bar and qdock tool bar.

2

There are 2 answers

0
nayana On

Why wont you make custom title bar? It can be anything bundled in QWidget.

QLabel *label = new QLabel("Header Text", myDock);
label->setStyleSheet("color: orange; font-size: 14pt; font-weight: bold;");
myDock->setWidget(bodyWidget);
myDock->setTitleBarWidget(label);

I've tested with Qt 5.3 it works, although there are missing buttons like close or undock :-/

I think that you can create them (with push button or so) and bundle everything in one widget, then set it with setTitleBarWidget and connect some signals. There is at least hide() slot for close button and you may have to code slot for float using setFloat.

0
marco On

I had the same problem and I've found out that the colour of the title can be changed in this way:

QDockWidget {
   color: white;
}

It's really bad (it will change all the widget's colour) but it works.