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. Scroll using the mouse wheel in a horizontal ScrollView

Scroll using the mouse wheel in a horizontal ScrollView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 3.5k 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.
  • Diego DonateD Offline
    Diego DonateD Offline
    Diego Donate
    wrote on last edited by
    #1

    I have a horizontal ScrollView with a ListView inside, and I want to scroll using the mouse wheel, but it seems not to work like it does in a vertical ScrollView.

    Do I need to add some extra code in the horizontal ScrollView?

    Thanks in advance,
    Diego

    My dummy code (with horizontal & vertical scrolls):

    import QtQuick 2.0
    import QtQuick.Controls 1.3
    
    Item {
    
        height: 500
        width: 600
    
        ScrollView {
            anchors { left: parent.left; leftMargin: 50; verticalCenter: parent.verticalCenter}
            height: 50
            width: 300
    
            ListView {
    
                height: 50
                width: contentWidth
    
                orientation: Qt.Horizontal
                interactive: false
                clip: true
    
                model: appModel
    
                delegate: Rectangle {
                    height: 50
                    width: 50
                    color: colorR
                   // Text { anchors.centerIn: parent; text: colorR }
                }
            } // ListView
        }
    
        ScrollView {
            anchors { right: parent.right; rightMargin: 50; verticalCenter: parent.verticalCenter}
            height: 300
            width: 50
    
            ListView {
                height: contentHeight
                width: 50
    
                interactive: false
                clip: true
    
                model: appModel
    
                delegate: Rectangle {
                    height: 50
                    width: 50
                    color: colorR
                   // Text { anchors.centerIn: parent; text: colorR }
                }
            } // ListView
        }
    
        ListModel {
            id: appModel
    
            ListElement { colorR: "red"}
            ListElement { colorR: "green"}
            ListElement { colorR: "blue"}
            ListElement { colorR: "cyan"}
            ListElement { colorR: "yellow"}
            ListElement { colorR: "blue"}
            ListElement { colorR: "lightgray"}
            ListElement { colorR: "red"}
            ListElement { colorR: "green"}
            ListElement { colorR: "blue"}
            ListElement { colorR: "cyan"}
            ListElement { colorR: "yellow"; }
            ListElement { colorR: "lightgray"}
        }
    }
    
    Arvindhan PonnusamyA 1 Reply Last reply
    0
    • Diego DonateD Diego Donate

      I have a horizontal ScrollView with a ListView inside, and I want to scroll using the mouse wheel, but it seems not to work like it does in a vertical ScrollView.

      Do I need to add some extra code in the horizontal ScrollView?

      Thanks in advance,
      Diego

      My dummy code (with horizontal & vertical scrolls):

      import QtQuick 2.0
      import QtQuick.Controls 1.3
      
      Item {
      
          height: 500
          width: 600
      
          ScrollView {
              anchors { left: parent.left; leftMargin: 50; verticalCenter: parent.verticalCenter}
              height: 50
              width: 300
      
              ListView {
      
                  height: 50
                  width: contentWidth
      
                  orientation: Qt.Horizontal
                  interactive: false
                  clip: true
      
                  model: appModel
      
                  delegate: Rectangle {
                      height: 50
                      width: 50
                      color: colorR
                     // Text { anchors.centerIn: parent; text: colorR }
                  }
              } // ListView
          }
      
          ScrollView {
              anchors { right: parent.right; rightMargin: 50; verticalCenter: parent.verticalCenter}
              height: 300
              width: 50
      
              ListView {
                  height: contentHeight
                  width: 50
      
                  interactive: false
                  clip: true
      
                  model: appModel
      
                  delegate: Rectangle {
                      height: 50
                      width: 50
                      color: colorR
                     // Text { anchors.centerIn: parent; text: colorR }
                  }
              } // ListView
          }
      
          ListModel {
              id: appModel
      
              ListElement { colorR: "red"}
              ListElement { colorR: "green"}
              ListElement { colorR: "blue"}
              ListElement { colorR: "cyan"}
              ListElement { colorR: "yellow"}
              ListElement { colorR: "blue"}
              ListElement { colorR: "lightgray"}
              ListElement { colorR: "red"}
              ListElement { colorR: "green"}
              ListElement { colorR: "blue"}
              ListElement { colorR: "cyan"}
              ListElement { colorR: "yellow"; }
              ListElement { colorR: "lightgray"}
          }
      }
      
      Arvindhan PonnusamyA Offline
      Arvindhan PonnusamyA Offline
      Arvindhan Ponnusamy
      wrote on last edited by
      #2

      @Diego-Donate I am not sure about the requirement .
      But you can find horizontal scrolling code in the link.

      https://stackoverflow.com/questions/15244527/fixing-horizontal-scrolling-in-qml

      Diego DonateD 1 Reply Last reply
      0
      • Arvindhan PonnusamyA Arvindhan Ponnusamy

        @Diego-Donate I am not sure about the requirement .
        But you can find horizontal scrolling code in the link.

        https://stackoverflow.com/questions/15244527/fixing-horizontal-scrolling-in-qml

        Diego DonateD Offline
        Diego DonateD Offline
        Diego Donate
        wrote on last edited by
        #3

        @Arvindhan-Ponnusamy Thanks for your help, i will try that

        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