PDA

View Full Version : Overriding ScrollView onWheel()



oberlus
4th June 2013, 17:36
Hi,

I have an Image loaded in a ScrollView and I have attempted to override the ScrollView onWheel behaviour as follows:



import QtQuick 2.1
import QtQuick.Controls 1.0

Rectangle {
id: root
color: "grey"

ScrollView {
id: scrollview
frameVisible: false
anchors.fill: parent

Image {
source: "qrc:/images/sample.jpg"

MouseArea {
anchors.fill: parent
onClicked: {
console.log("onClicked")
}

onWheel: {
console.log("onWheel")
}
}
}
}
}


When run if I click on the image the onClicked() is called ok, but if I move the mouse wheel the onWheel is never called.

What am I doing wrong?

Eventually (if I can get it to work) I would like to override it in such a way that moving the mouse wheel while holding the control key down calls some application specific code. Moving the wheel without holding the control key should allow the ScrollView to move the scrollbar. Something like:




onWheel: {
console.log("onWheel")
if (wheel.modifiers & Qt.ControlModifier)
doSomething(wheel)
else
how_do_I_call_the_normal_behaviour?
}


2. Any ideas on how to call the default behaviour? Is there a way to not consume the event so that the parent can do so?

Thanks for any help