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

QQC2: TabBar doesn't allow scrolling to change tabs

    XMLWordPrintable

Details

    • 2ead10bf55 (qt/qtdeclarative/dev) 5f26ab4c8e (qt/qtdeclarative/6.2) 5d1dff31f6 (qt/qtdeclarative/6.3) 5f26ab4c8e (qt/tqtc-qtdeclarative/6.2) 5d1dff31f6 (qt/tqtc-qtdeclarative/6.3) 2ead10bf55 (qt/tqtc-qtdeclarative/dev) 5f26ab4c8e (qt/qtdeclarative/6.2.4)

    Description

      It should be possible to make scrolling with a mouse wheel or touchpad change the currentIndex by setting wheelEnabled to true in a TabBar. This would be far more convenient than what we currently have to do to get this behavior. QTabBar also allows scrolling to change tabs, so this would bring Qt Quick Controls closer to feature parity with Qt Widgets on desktop.

      What I'd like:

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      
      ApplicationWindow {
          width: 400
          height: 400
          visible: true
      
          TabBar {
              wheelEnabled: true
              TabButton { text: "tab1" }
              TabButton { text: "tab2" }
              TabButton { text: "tab3" }
          }
      }
      

      What I currently have to do:

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      
      ApplicationWindow {
          width: 400
          height: 400
          visible: true
      
          TabBar {
              id: tabBar
              TabButton { text: "tab1" }
              TabButton { text: "tab2" }
              TabButton { text: "tab3" }
              // We need an Item over everything because TabButtons block
              // wheel events from reaching the TabBar.
              Item {
                  parent: tabBar
                  z: 1
                  anchors.fill: parent
                  WheelHandler {
                      orientation: Qt.Vertical
                      onWheel: if (rotation <= -15) {
                          rotation = 0
                          tabBar.incrementCurrentIndex()
                      } else if (rotation >= 15) {
                          rotation = 0
                          tabBar.decrementCurrentIndex()
                      }
                  }
                  WheelHandler {
                      orientation: Qt.Horizontal
                      onWheel: if (rotation <= -15) {
                          rotation = 0
                          tabBar.incrementCurrentIndex()
                      } else if (rotation >= 15) {
                          rotation = 0
                          tabBar.decrementCurrentIndex()
                      }
                  }
              }
          }
      }
      

      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
            ndavis Noah Davis
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes