Using Qt stylesheets, is it possible to set a different background colour for each tab in a QTabBar that has 4 or more tabs?
My Qt application has 6 tabs underneath the menu bar. I'd like to change their background colours to 6 different colours using stylesheets.
2 issues appear to be standing in my way:
I can only style the "first", "middle", and "last" tabs using pure stylesheet syntax (hence why I say "4 or more" tabs).
I don't think the individual tabs are child widgets of the QTabBar that I can access. The idea being that I could then attach a property to each child tab that I could reference in the stylesheet.
For example:
// Stylesheet
QTabBar::tab[index="3"] {
background: blue;
}
// Code
QTabBar* bar = new QTabBar;
int index = bar->addTab("Tab 1");
QWidget* tab1; //= ????
tab1->setProperty("index", index);
Any help would be much appreciated. Thanks.