Results 1 to 15 of 15

Thread: Scrolling listview with mouse wheel on Android

  1. #1

    Default Scrolling listview with mouse wheel on Android

    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:

    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 1.1
    3.  
    4. Item {
    5. id: root
    6.  
    7. Rectangle {
    8. id: scrollBar
    9. width: 5
    10. height: listView.visibleArea.heightRatio * (listView.height - 10)
    11. y: 5 + listView.visibleArea.yPosition * (listView.height - 10)
    12. x: parent.width - width - 3
    13. z: 1000
    14. visible: listView.visibleArea.heightRatio < 1
    15. color: "#bbbbbb"
    16. radius: 14
    17. }
    18.  
    19.  
    20. ListView {
    21. id: listView
    22. width: parent.width; height: parent.height
    23. //clip: true
    24. pixelAligned: true
    25. boundsBehavior: Flickable.StopAtBounds
    26.  
    27. model: ContactModel {}
    28. delegate: contactDelegate
    29.  
    30. MouseArea {
    31. anchors.fill: parent
    32. acceptedButtons: Qt.NoButton
    33. onWheel: {
    34. wheel.accepted = true
    35. if (wheel.angleDelta.y !== 0) {
    36. listView.flick(0, wheel.angleDelta.y * 5)
    37. }
    38. }
    39. }
    40. }
    41.  
    42. Component {
    43. id: contactDelegate
    44. Item {
    45. width: 180; height: 50
    46. Column {
    47. Text {
    48. text: '<b>Name:</b> ' + name
    49. color: "white"
    50. font.pixelSize: 20
    51. }
    52. Text {
    53. text: '<b>Number:</b> ' + number
    54. color: "white"
    55. font.pixelSize: 20
    56. }
    57. }
    58. }
    59. }
    60. }
    To copy to clipboard, switch view to plain text mode 

    Have any suggestions?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling listview with mouse wheel on Android

    Does it work on a desktop?

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

    Cheers,
    _

  3. #3

    Default Re: Scrolling listview with mouse wheel on Android

    It works on Desktop, but not on Android device.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling listview with mouse wheel on Android

    Hmm, and the wheel event works when the mouse area is not inside a flickable?

    Cheers,
    _

  5. #5

    Default Re: Scrolling listview with mouse wheel on Android

    I don't understand your question.

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

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling listview with mouse wheel on Android

    Quote Originally Posted by LepaBrena View Post
    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?

    Quote Originally Posted by LepaBrena View Post
    For given example, mouse wheel works in Desktop app but in Android app it does not.
    Yes, you already wrote that.

    Cheers,
    _

  7. #7

    Default Re: Scrolling listview with mouse wheel on Android

    I've tried this example. Same problem for Android. Squares are not resizing.

    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Rectangle {
    4. height: 700
    5. width: 485
    6. color: "#333333"
    7.  
    8. Column {
    9. anchors.centerIn: parent
    10. spacing: 2
    11.  
    12. Repeater {
    13. model: ["#9ACD32", "#EEEEEE", "#FFD700", "#87CEEB"]
    14.  
    15. Rectangle {
    16. property real scaleFactor: 1
    17.  
    18. height: 40 * scaleFactor
    19. width: 60 * scaleFactor
    20. color: modelData
    21. anchors.horizontalCenter: parent.horizontalCenter
    22.  
    23. MouseArea {
    24. anchors.fill: parent
    25. onWheel: {
    26. if (wheel.angleDelta.y > 0)
    27. parent.scaleFactor += 0.2;
    28. else if (parent.scaleFactor - 0.2 >= 0.2)
    29. parent.scaleFactor -= 0.2;
    30. }
    31. }
    32. }
    33. }
    34. }
    35.  
    36. Text {
    37. anchors.bottom: parent.bottom
    38. anchors.horizontalCenter: parent.horizontalCenter
    39. color: "#FFD700"
    40. text: "Rotate the mouse wheel pressing <Control> to resize the squares."
    41. }
    42. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling listview with mouse wheel on Android

    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:
    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. MouseArea {
    4. // some widh/height
    5.  
    6. onWheel: console.log("wheel, delta=" + wheel.angleDelta);
    7. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  9. #9

    Default Re: Scrolling listview with mouse wheel on Android

    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
    Last edited by LepaBrena; 28th November 2016 at 13:56.

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling listview with mouse wheel on Android

    Then it seems Wheel events are not working on Android.

    Maybe check if there is a bug report for that.

    Cheers,
    _

  11. #11

    Default Re: Scrolling listview with mouse wheel on Android

    I've found this:
    https://bugreports.qt.io/browse/QTBU...l%20android%22

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

  12. #12
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling listview with mouse wheel on Android

    This does indeed sound like the problem you are experiencing.

    Which version of Qt are you using?

    Cheers,
    _

  13. #13

    Default Re: Scrolling listview with mouse wheel on Android

    Exactly Qt 5.3.2.

  14. #14

    Default Re: Scrolling listview with mouse wheel on Android

    After updating Qt, problem is still there.

  15. #15

    Default Re: Scrolling listview with mouse wheel on Android

    It was Qt problem. The problem is solved.
    https://bugreports.qt.io/browse/QTBUG-43669

Similar Threads

  1. zooming with ctrl + mouse wheel
    By alperyazir66 in forum Qwt
    Replies: 2
    Last Post: 19th May 2015, 11:46
  2. Replies: 0
    Last Post: 4th January 2013, 04:59
  3. Replies: 0
    Last Post: 6th March 2012, 10:56
  4. Can usb mouse wheel work in Qt/E ?
    By earth in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th August 2011, 11:00
  5. Scrolling on Mouse Wheel
    By penny in forum Qt Programming
    Replies: 4
    Last Post: 7th April 2011, 07:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.