Styling QTabBar of concrete QTabWidget

  • Hello,
    I am creating my first app in QT and I need to have 2 differently styled QTabWidgets. I styled the first one with something like this in .qss file:

    @ QTabWidget::tab-bar {
    left: 5px;
    QTabBar::tab {
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
    stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);

    ... (there is more of it but it isnt very relevant)

    Now the problem is, that I cant find a way to change style of the second QTabWidget because I cant find a way to specify his QTabBar. Via QT creator I have created QTabWidget and named it GraphTabWidget and into .qss file I wrote:

    @QTabWidget#GraphTabWidget:pressed { //This worked fine
    background-color: red;


    @QTabBar#GraphTabWidget:tab { //This has no effect
    background-color: black

    So the question is: What do I need to write to .qss file to change style of QTabBar of my GraphTabWidget?

    I have also tried to use @ui->GraphTabWidget->tabBar()->setStyleSheet(); @
    but it did really strange things (I could change a color of borders, but nothing else and even when I used 'setStyleSheet("")' it didnt reset the style to default).

    I will much appreciate any help :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.