Important: Please read the Qt Code of Conduct -

QTabBar scrolls back to beginning automatically on tab text update

  • I have a QTabWidget with many tabs, so the scroll buttons appear on the right side of the tab bar.


    The tab titles get updated from time to time. Whenever any of the tab titles gets updated, the scroll jumps automatically to the beginning. Sometimes the updates are pretty frequent so it gets kind of hard to click a tab on the right end.

    Is there a way of preventing the automatic scroll to the left when a tab text gets updated?

    You can check this behavior by creating a new QWidget-based project on Qt. Drop a QTabWidget on the form and use the following code to auto-update the title of the first tab:

    Widget::Widget(QWidget* parent)
        : QWidget(parent)
        , ui(new Ui::Widget)
        for (int i = 1; i < 20; ++i) {
            ui->tabWidget->addTab(new QWidget(this), QString("Tab %1").arg(i));
        auto timer = new QTimer(this);
        connect(timer, &QTimer::timeout, [=]() {
            static int i = 0;
            ui->tabWidget->setTabText(0, QString("Tab %1").arg(i));

    Thanks in advance.

  • Lifetime Qt Champion

    I vaguely remember such a bug in the bug tracker but think it was closed already - what Qt version do you use?

  • @Christian-Ehrlicher I use 5.9.4. I'm afraid I cannot upgrade to any other version for now.

  • Lifetime Qt Champion

    See - it worked for me with 5.111 so I closed the issue.

Log in to reply