0
votes

Is there any way to set two different qss style rules for two QTabWidgets tabs. I can set style rule for all tab like this:

QTabBar::tab {...}

But it will set the stye for all tab bars of QTabWidgets

How to set QTabBar tab style for certain instance of QTabWidget?

1
You use the setStyleSheet() on wich object ?thibsc
Oh, thanks. I set style for entire app. I foolishly forgot I can do that for any objectMetlab
yes you can do that on each object but you can also use the object name as an ID, like QTabWidget#myobjname { ... }thibsc

1 Answers

1
votes

You can use the QObject::setObjectName(const QString &name) function to give every QTabWidget a different name and then set the style for a particular QTabWidget using its name:

QTabWidget#tabname {...}

Alternatively you can do the same on the code side without using the setObjectName() function but setting the stylesheet directly to the widget itself like this:

ui->tabWidget->setStyleSheet(...);