PDA

View Full Version : Scroll using the mouse wheel in a horizontal ScrollView



ddonate
5th September 2017, 15:31
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"}
}
}