PDA

View Full Version : Scrolling listview with mouse wheel on Android



LepaBrena
7th November 2016, 09:42
I've tried so much examples: with scrollview, flicable, scrollbar, mousearea, but nothing works. Like there is not mouse wheel event at all.

This is example:


import QtQuick 2.0
import QtQuick.Controls 1.1

Item {
id: root

Rectangle {
id: scrollBar
width: 5
height: listView.visibleArea.heightRatio * (listView.height - 10)
y: 5 + listView.visibleArea.yPosition * (listView.height - 10)
x: parent.width - width - 3
z: 1000
visible: listView.visibleArea.heightRatio < 1
color: "#bbbbbb"
radius: 14
}


ListView {
id: listView
width: parent.width; height: parent.height
//clip: true
pixelAligned: true
boundsBehavior: Flickable.StopAtBounds

model: ContactModel {}
delegate: contactDelegate

MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: {
wheel.accepted = true
if (wheel.angleDelta.y !== 0) {
listView.flick(0, wheel.angleDelta.y * 5)
}
}
}
}

Component {
id: contactDelegate
Item {
width: 180; height: 50
Column {
Text {
text: '<b>Name:</b> ' + name
color: "white"
font.pixelSize: 20
}
Text {
text: '<b>Number:</b> ' + number
color: "white"
font.pixelSize: 20
}
}
}
}
}

Have any suggestions?

anda_skoa
8th November 2016, 17:39
Does it work on a desktop?

I.e. does it just not work on Android or not at all?

Cheers,
_

LepaBrena
11th November 2016, 13:57
It works on Desktop, but not on Android device.

anda_skoa
11th November 2016, 18:35
Hmm, and the wheel event works when the mouse area is not inside a flickable?

Cheers,
_

LepaBrena
22nd November 2016, 12:14
I don't understand your question.

For given example, mouse wheel works in Desktop app but in Android app it does not.

anda_skoa
22nd November 2016, 12:54
I don't understand your question.

If you have a MouseArea anywhere else than inside a list view delegate, does the wheel event work there?



For given example, mouse wheel works in Desktop app but in Android app it does not.
Yes, you already wrote that.

Cheers,
_

LepaBrena
28th November 2016, 09:00
I've tried this example. Same problem for Android. Squares are not resizing.


import QtQuick 2.0

Rectangle {
height: 700
width: 485
color: "#333333"

Column {
anchors.centerIn: parent
spacing: 2

Repeater {
model: ["#9ACD32", "#EEEEEE", "#FFD700", "#87CEEB"]

Rectangle {
property real scaleFactor: 1

height: 40 * scaleFactor
width: 60 * scaleFactor
color: modelData
anchors.horizontalCenter: parent.horizontalCenter

MouseArea {
anchors.fill: parent
onWheel: {
if (wheel.angleDelta.y > 0)
parent.scaleFactor += 0.2;
else if (parent.scaleFactor - 0.2 >= 0.2)
parent.scaleFactor -= 0.2;
}
}
}
}
}

Text {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
color: "#FFD700"
text: "Rotate the mouse wheel pressing <Control> to resize the squares."
}
}

anda_skoa
28th November 2016, 11:33
Why again such a complicated example?
Why not try the most simple possible example just to see if wheel event in general doesn't work?

Always go for a test case that is as simple as possible!

A single MouseArea as the top level item should do:


import QtQuick 2.0

MouseArea {
// some widh/height

onWheel: console.log("wheel, delta=" + wheel.angleDelta);
}


Cheers,
_

LepaBrena
28th November 2016, 13:46
I've tried it first, but ok. This is result:

Windows:
qml: wheel, delta=QPoint(0, -120)
qml: wheel, delta=QPoint(0, -120)
qml: wheel, delta=QPoint(0, -120)
qml: wheel, delta=QPoint(0, -120)
qml: wheel, delta=QPoint(0, 120)
qml: wheel, delta=QPoint(0, 120)
qml: wheel, delta=QPoint(0, 120)
qml: wheel, delta=QPoint(0, 120)

Android:
Nothing

anda_skoa
29th November 2016, 06:55
Then it seems Wheel events are not working on Android.

Maybe check if there is a bug report for that.

Cheers,
_

LepaBrena
29th November 2016, 11:10
I've found this:
https://bugreports.qt.io/browse/QTBUG-43669?jql=text%20~%20%22mouse%20wheel%20android%22

How to know is this just for Qt 5.3 without installing another version of Qt? Any idea?

anda_skoa
29th November 2016, 12:29
This does indeed sound like the problem you are experiencing.

Which version of Qt are you using?

Cheers,
_

LepaBrena
29th November 2016, 12:55
Exactly Qt 5.3.2.

LepaBrena
30th November 2016, 13:39
After updating Qt, problem is still there.

LepaBrena
16th August 2017, 07:47
It was Qt problem. The problem is solved.
https://bugreports.qt.io/browse/QTBUG-43669