user8083903
user8083903

Reputation:

How can I change the color of the text in the tab of a QTabWidget

I'm not talking about the stuff within the tab, but the tab itself. Aside from it looking weird, I'd like to closely emulate Mac's native look. Here's a screenshot of some system settings settings screenshot

and here's a pic of what I have.

enter image description here

I've tried

QTabWidget tabWidget; tabWidget.setStyleSheet("color: #ffffff");

but that just changes all the text within the tab widget itself. Any help?

Upvotes: 1

Views: 6979

Answers (3)

GAVD
GAVD

Reputation: 2134

I used this way:

tabWidget->tabBar()->setStyleSheet("QTabBar::tab:selected {\
                                   color: #00ff00;\
                                   background-color: rgb(0,0,255);\
                               }");

or, for only one tab:

tabWidget->tabBar()->setTabTextColor(1,Qt::white);

Upvotes: 2

Marco
Marco

Reputation: 2020

I would try this way:

QTabWidget tabWidget;
tabWidget.setStyleSheet("QTabBar::tab:selected { color: #ffffff; }");

In my example this works!

Upvotes: 0

Farhad
Farhad

Reputation: 4181

You can use style Sheet like this:

ui->tabWidget->setStyleSheet("color: rgb(119, 133, 255);");

Or use QTabWidget functions for specific item:

ui->tabWidget->item(i,j)->setTextColor(QColor(color));
ui->tabWidget->item(i,j)->setBackgroundColor(QColor(color));

Upvotes: 0

Related Questions