2
votes

I can't seem to change the size of the tab bar. The tabs are incredibly small, and I can do it through the "gui" tool in the examples. Can I do this programatically, or am I missing something?

QTabWidget::pane {

    //border-top: 2px solid #C2C7CB;

    //doesn't work, neither does 20px
    //height:20ex;
}

QTabWidget::tab-bar {

    //doesn't work, neither does 20px
    //height:20ex; 

    //doesn't work, neigher does 20px
    //min-height:10ex;
}

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);
        border: 1px solid #C4C4C3;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        padding: 2px;


    //tried using font size to increase tab size, doesn't work
    font-size: 20px;
 }
4

4 Answers

2
votes

It should be like this:

QTabBar::tab {width: 100px; height: 20px;}
2
votes

Setting QTabBar::tab { width: 100px; height: 20px; } in CSS did not work, even though other values were affected by CSS (background color, etc.).

Setting it programatically worked:

tabWidget->setStyleSheet("QTabBar::tab { width: 100px; height: 20px; }");
0
votes

check which style sheet you're eduting. the best one to edit is the widget/main window one.

0
votes

If only the height or the width attribute is provided then your tab will not apply the property.

Only if both the height and the width attributes in your css file, will the tab apply the properties.

QTabBar::tab {
    height: 20px;
    width: 200px   
}

not

QTabBar::tab {
    height: 20px;
}