[Solved] QTabWidget, change tab's background-color
-
wrote on 20 Oct 2013, 20:43 last edited by
How to change a QTabWidget's tab's background color?
I've tried every single solutions found on Internet but nothing works.The closest I've got to actually changing the style of a tab is using this
@ui->Wdgt_Inbox->tabBar()->setTabTextColor(0, "black");@
Unfortunately, there's no setTabBackgroundColor option.
@
ui->Wdgt_Inbox->tabBar()->setCurrentIndex(0);ui->Wdgt_Inbox->tabBar()->setStyleSheet("background-color:cyan;");
ui->Wdgt_Inbox->tabBar()->setStyleSheet("QWidget { background-color:cyan; }");
ui->Tab_Inbox->setStyleSheet("background-color:cyan;");
@ -
You need to apply the style to the tabwidget itself, not the tab bar, and use a ::tab sub-control.
Take a look "here":http://qt-project.org/doc/qt-5.1/qtwidgets/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar for an example. -
wrote on 20 Oct 2013, 22:12 last edited by
I've found something quite strange while playing around.
When you change the QTabWidget's tabShape to triangular, your tabs inherit the QTabWidget's background color.
And the good thing is, triangular tabs look even better than rounded ones.
Now if only i could find a way to get rid of that awful white border around the QTabWidget I'd be in heaven.
-
wrote on 20 Oct 2013, 22:17 last edited by
[quote author="Chris Kawa" date="1382307057"]You need to apply the style to the tabwidget itself, not the tab bar, and use a ::tab sub-control.
Take a look "here":http://qt-project.org/doc/qt-5.1/qtwidgets/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar for an example.[/quote]Oh, thanks.
I didn't see your reply because we replied at the same time.
1/4