Change the design in QTabWidget



  • Hi all!
    My program has a QTabWidget. And QTabWidget has a QListWidget.
    I don't like that QTabWidget is white, and I wanted to change the color to another(on example to gray, like in QDialog. )
    So, when I changed the StyleSheet in QTabWidget, all things in this widget became gray. And QListWidget too. But I want to change only QTabWidget's color, and don't touch other things(QListWidget and other).

    What should I do? Thanks.


  • Qt Champions 2016

    hi
    make sure your style sheet only apply to the classes you want, byt putting the class name in front
    QTabWidget { xxxx }
    else it applies to all other widgets too.

    http://doc.qt.io/qt-5/stylesheet-examples.html



  • @mrjj it doesn't work. QTabWidget continue to be just white.
    But if I make the code for QMainWindow-it's working.
    Code:

    QTabWidget{
    background-color:#1d1d1d;
    }
    

    And it doesn't change anything. I don't know what is wrong in my code.


  • Qt Champions 2016

    hi
    it does work but it colors background of the QTabWidget, which is up where the
    tabs are. it is NOT the area of the tabs area.
    Not sure there are anything there to address.
    else try with mainwindow with
    Qwidget#NameOFhteQTabWidget {
    background-color:#1d1d1d;
    }


  • Moderators

    To style the content area of the tab you need to use QTabWidget::pane. As with many other widgets the background is drawn by a platform style and setting only the background color will not override it. A usual trick for that is setting a border too, which overrides the style and makes the widget use properties like background color:

    tabWidget->setStyleSheet("QTabWidget::pane { border: none; background-color: #1d1d1d; }");
    

Log in to reply
 

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