If you subclass QTabWidget, you can access the protected function QTabWidget::tabBar()
, which returns the QTabBar used. QTabBar has a QTabBar::setTabTextColor()
method that will change the text color of an individual tab. Here is an example:
#include <QtGui> class TabWidget : public QTabWidget { public: TabWidget() { addTab(new QPushButton("Hi 1!"), "Button 1 Tab"); addTab(new QPushButton("Hi 2!"), "Button 2 Tab"); tabBar()->setTabTextColor(0, QColor(Qt::red)); tabBar()->setTabTextColor(1, QColor(Qt::blue)); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); TabWidget tabWidget; tabWidget.show(); return app.exec(); }
If you need more control, you can create your own tab widget. According to docs , a QTabWidget is basically a QStackedWidget combined with a QTabBar. You can create your own tab widget by combining a QStackedWidget with, for example, a set of stylized QPushButtons.
source share