Using Qt's style sheets, is it possible to set a different background color for each tab in a QTabBar with 4 or more tabs?
My Qt application has 6 tabs under the menu bar. I would like to change their background colors to 6 different colors using style sheets.
There seem to be 2 questions in my way:
I can only stylize the tabs "first", "middle" and "last", using the syntax of a clean style sheet (from here I say "4 or more" tabs).
I don’t think the individual tabs are child QTabBar widgets that I can access. The idea was that I could then bind a property to each child tab that I could reference in the stylesheet.
For instance:
QTabBar::tab[index="3"] {
background: blue;
}
QTabBar* bar = new QTabBar;
int index = bar->addTab("Tab 1");
QWidget* tab1;
tab1->setProperty("index", index);
. .