Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTabBar scrolls back to beginning automatically on tab text update

QTabBar scrolls back to beginning automatically on tab text update

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 450 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JoseTomasTocino
    wrote on last edited by
    #1

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

    3e07fe7b-cbdc-4512-8de3-b9589f683e58-image.png

    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)
    {
        ui->setupUi(this);
    
        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;
            i++;
            ui->tabWidget->setTabText(0, QString("Tab %1").arg(i));
        });
    
        timer->start(1000);
    }
    

    Thanks in advance.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

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

        J Offline
        J Offline
        JoseTomasTocino
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          See https://bugreports.qt.io/browse/QTBUG-27084 - it worked for me with 5.111 so I closed the issue.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved