Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-134434

Close buttons in QTabBar do not move when scrolling with trackpad on Mac

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.2
    • None
    • macOS

    Description

      When using the Mac trackpad to scroll horizontally through tabs in a QTabBar/QTabWidget, the close buttons of the tabs do not move with the tabs. They stay fixed instead. When changing active tabs or resizing, they snap back to the correct position.

      My best guess is that the problem is in the WheelEvent of qtabbar.cpp, around line 2408, where a call to d->layoutWidgets(); should be added after the update(), analogously to what is done in line 707. But I didn't manage to build Qt on my machine so couldn't test this.

      The same bug was reported in a project using Qt here: https://github.com/texstudio-org/texstudio/issues/3280

      Small example app that illustrates the problem:

      #include <QApplication>
      #include <QTabWidget>
      #include <QWidget>
      #include <QVBoxLayout>
      #include <QLabel>
      #include <QStyle>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          
          app.setStyle("Fusion");
          
          QWidget mainWindow;
          mainWindow.setWindowTitle("QTabWidget Demo");
          mainWindow.resize(400, 300);
          
          QVBoxLayout *layout = new QVBoxLayout(&mainWindow);
          QTabWidget *tabWidget = new QTabWidget();
          
          tabWidget->setUsesScrollButtons(true);
          tabWidget->setTabsClosable(true);
          tabWidget->setElideMode(Qt::ElideRight);
          
          for (int i = 1; i <= 10; ++i) {
              QWidget *tab = new QWidget();
              QVBoxLayout *tabLayout = new QVBoxLayout(tab);
              QLabel *label = new QLabel(QString("This is the content for Tab %1").arg(i));
              tabLayout->addWidget(label);
              tabWidget->addTab(tab, QString("Tab %1 with Long Title").arg(i));
          }
          
          layout->addWidget(tabWidget);
          mainWindow.show();
          return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dominikpeters Dominik Peters
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes