Search code examples
qtqstylesheet

How to customize tab header for QTabBar with a custom witdh=max? (qt style sheet)


I would like a TabBar like that but I don't which parameters of TabBar that I must set? (I want to use only style sheet)

I tried this :

QTabWidget::tab-bar {

    background-color: blue;

    min-width:2000;

    with:2000;

    height:50;

}

but there are no changes on the screen

enter image description here

This is the full solution :

QTabWidget QTabBar{
background-color: #136ba2;
width: 256px;
font: 10pt "Arial";
}

QTabWidget QTabBar::tab{
background-color: #136ba2;
height: 50px;
width: 256px;
color: #e6e6e6;
}

QTabWidget QTabBar::tab:selected{
background-color: #0f5d90;
width: 256px;
}

QTabBar::tab:last {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    margin-right: 678px;
}

Solution

  • Instead of using QTabWidget::tab-bar{} try using QTabWidget QTabBar{}. To set more specific attributes, use the ::tab selector.

    For example:

    QTabWidget QTabBar{background-color: #136ba2; min-width: 2000px;}
    QTabWidget QTabBar::tab{background-color: #136ba2; height: 50px; color: #e6e6e6}
    QTabWidget QTabBar::tab:selected{background-color: #0f5d90;}