Important: Please read the Qt Code of Conduct -

Fixing Tab-size in a QTabWidget

  • I added a QTabWidget in my interface at design time.
    I am adding tabs to the widget at run time using the following code.

    @ tabWidget->setStyleSheet("QTabBar::tab { max-width: 100px; }");
    tabWidget->addTab(new QWidget(),fileName);@

    I need to fix the size of a Tab. Above style sheet is not working and QTabWidget does not follow this max-width restriction.
    Am I missing something in my code or Is there another way of doing this?

    Any help is appreciated.

  • Maybe try with;
    tabWidget->setExpanding (false);

Log in to reply