0
votes

I have been trying to set the background color of a QTabWidget to black (or any other color for), but have been unsuccessful in doing so.

enter image description here

It seems that you need the option autoFillBackground set and then also set "background-color: black;" in the stylesheet. This then displays it properly in the Designer, but fails in the application.

This answer suggests to enclose it in another QWidget and then use the transparency, but that is a hack around the issue.

How do I set the background color of a QTabWidget via stylesheets?

EDIT

Setting QTabBar { background-color: black; } results in the following image.

enter image description here

1
I have the same problem as you, I'm unable to set the tabbar background color as you have described in your edit. My issue is only happening on documentMode in OSX doc.qt.io/qt-5/qtabwidget.html#documentMode-propEd Knowles

1 Answers

0
votes

As an alternative to QTreeWidget, use QTabBar + QStackedWidget and the following stylesheet

QTabBar { background-color: black; }

or use Qt: Styling QTabWidget