Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
5.15.7, 6.x
-
None
-
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() } } } } }