QTabBar Tab Size Does Not Scale with Style Font

I have a stylesheet:

QTabBar::tab {

background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,
                        stop: 0 #2A2A2A, stop: 0.4 #E1E1E1,
                        stop: 0.5 #E1E1E1, stop: 1.0 #2A2A2A);
background-image: url(:/metal_toolbar);
border-left: 1px solid #9B9B9B;
border-right: 1px solid #9B9B9B;
border-bottom: 1px solid #9B9B9B;
border-top-color: #5A5A5A;
font: bold 12pt;
/*min-width: 20ex;
max-width: 1000ex;*/
padding: 2px;
}

If I do not declare the font in the stylesheet, my tabs correspond accordingly to the text they contain, however, when I increase the font size, the tab size remains constant and the text becomes disabled. I tried all the width settings, but I want the tab width to be scaled to what it contains.

Does anyone know a workaround or fix for this?

I load the stylesheet file into my program as a skin, so I would prefer to use style solutions over software solutions if they exist

EDIT:

Here is the working version with the correct tab sizes

QTabBar
{
    font: bold 9pt;
}

 QTabBar::tab 
 {

    background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,
                            stop: 0 #2A2A2A, stop: 0.4 #E1E1E1,
                            stop: 0.5 #E1E1E1, stop: 1.0 #2A2A2A);
    background-image: url(:/metal_toolbar);
    border-left: 1px solid #9B9B9B;
    border-right: 1px solid #9B9B9B;
    border-bottom: 1px solid #9B9B9B;
    border-top-color: #5A5A5A;
    min-width: 20ex;
    padding: 2px;
 }
+4
1

QTabBar. .

font = tabbar.font()
font.setPointSize(12)
font.setBold(true)
tabbar.setFont(font)

QTabBar QTabWidget . , .

+2

All Articles