user2563661 user2563661 - 5 months ago 48
C++ Question

QToolBar background color only applies to actions

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


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?


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.


Ok, so I did some digging and found this . 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.