QToolBar background color only applies to actions

user2563661 picture user2563661 · Jul 27, 2015 · Viewed 8.3k times · Source

I am trying to set the bacground color of a QToolBar in Qt designer with the following in stylesheet background : rgb(30, 30, 30). For some reason the background color is only applied to the action's background as can be seen in the image. How can I change the color of the whole toolbar?

enter image description here

Edit.

Even if I change the background color of my whole window, the area of toolbar is not affected:

enter image description here

This is an empty default Qt widgets application where I only added a QToolBar and one QAction and in the stylesheet of my QMainWindow

background : red;
QToolBar { background : red }
QToolButton {background : red}

Is this expected behaviour or a bug on qt with linux?

edit.

I tried this code on Xubuntu 14.04 with Qt 4.8 and Qt 5.4.2. This seems to be a bug on Qt. See my own answer below.

Answer

user2563661 picture user2563661 · Jul 27, 2015

Ok, so I did some digging and found this https://forum.qt.io/topic/23800/solved-change-background-color-of-qtoolbar-doesn-t-work-in-linux . Apparently this is a specific problem on some Linux distributions. Adding border: none after the background : rgb(30, 30, 30) fixed the problem. Don't know why my question was downvoted though.