Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Tumbler doesn't respond on mouse wheel
Qt 6.11 is out! See what's new in the release blog

Tumbler doesn't respond on mouse wheel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 113 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.
  • M Offline
    M Offline
    MarNem
    wrote last edited by
    #1

    Hi! I need to use Tumbler in my project (Qt 6.11), but it doesn't seem to respond to mouse wheel (responds to touch though). I was expecting it to be out of the box behavior. How to make it work?

    Window {
        width: 640
        height: 800
        visible: true
        title: qsTr("Hello World")
    
        Tumbler {
                id: testTumbler
                width: 200
                height: 600
                model: ["1", "2", "3", "4", "5"]
                wheelEnabled: true
        }
    }
    

    I tried

        Tumbler {
                id: testTumbler
                width: 200
                height: 600
                model: ["1", "2", "3", "4", "5"]
                wheelEnabled: true 
                hoverEnabled: true
                focus: hovered
        }
    

    It didn't help.

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote last edited by
      #2

      You should take a look at examples by QT for Tumbler QML;

      https://doc.qt.io/qt-6/qml-qtquick-controls-tumbler.html

      Try this, or parts of this code, this works for me;

      import QtQuick
      import QtQuick.Controls
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Mouse wheel action")
      
          Rectangle {
              color: "khaki"
              anchors.centerIn: parent
              width: frame.implicitWidth + 10
              height: frame.implicitHeight + 10
      
              Frame {
                  id: frame
                  anchors.centerIn: parent
      
                  Row {
                      id: row
                      Tumbler {
                          id: tumbler
                          model: 5
                          width: 200; height: width
                          focus: true; wheelEnabled: false
                          delegate: Text {
                              text: modelData
                              font.pixelSize: 18
                              horizontalAlignment: Text.AlignHCenter
                              verticalAlignment: Text.AlignVCenter
                              opacity: 1.0 - Math.abs(Tumbler.displacement) / (tumbler.visibleItemCount / 2)
      
                              required property var modelData
                              required property int index
                          }
                      }
                      WheelHandler {
                          onWheel: (event) => {
                              tumbler.currentIndex += event.angleDelta.y > 0 ? -1 : 1
                          }
                      }
                  }
              }
          }
      }
      

      p.s. My mouse is old and the scroll wheel is very intermittent, but I think the above should help.

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0

      • Login

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