Scroll using the mouse wheel in a horizontal ScrollView



  • 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"}
        }
    }
    


  • @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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.