Important: Please read the Qt Code of Conduct -

How to control TabBar width in MdiSubwindow

  • I would like to title text in tabbed view mode of MDI subwindow to adjust to text length. Currently, it is too wide.

  • You can get hold of the underlying tabbar and call setExpanding(false) on it, see the "documentation":

    The following example illustrates how this can be done:


    #include <QtGui>
    int main(int argc, char **argv)
    QApplication app(argc, argv);
    QMainWindow window;

    QMdiArea *area = new QMdiArea(&window);
    QMdiSubWindow *first = area->addSubWindow(new QLineEdit(area));
    QMdiSubWindow *second = area->addSubWindow(new QLineEdit(area));
    QList<QTabBar *> tabBarList = area->findChildren<QTabBar*>();
    QTabBar *tabBar =;
    if (tabBar) {

    return app.exec();
    Does this give you the result you are looking for?

  • I found that tabBar is accessible. However, visual result did not change after expanding() is set to false.

  • When running the example I pasted above, do the tabs adjust to the length of the text? If so, can you modify the example so that it shows your problem? Which version of Qt are you using and on which platform?

Log in to reply