Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. onWheel not working in Flickable
QtWS25 Last Chance

onWheel not working in Flickable

Scheduled Pinned Locked Moved General and Desktop
flickablewheelonwheelmouseareaqml
3 Posts 2 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ajvanho6
    wrote on 7 Oct 2015, 15:31 last edited by p3c0 10 Aug 2015, 06:19
    #1

    Hello i am trying to implement mouse wheel scrolling over Flickable area. Rectangle which is inside Flickable is kind a menu content container. And it holds menu items which number is changing. So i used Flickable to get that container scrolling but it works when you press a mouse and drag but scroll wheel is not working. I tried to put Item element outside flickable and wrap everything up but then flickable is not working.

    Here is the code

    import QtQuick 2.1
    
    Flickable {
        signal drag(string mouseY)
        id: flickable
        contentWidth: itemscontent.width
        contentHeight: 712
        flickableDirection: Flickable.VerticalFlick
        clip: true
        width: parent.width
        interactive: true
        boundsBehavior: Flickable.StopAtBounds
        anchors.fill: parent
    
        MouseArea {
            anchors.fill: parent
            onWheel: flickable.drag(mouse.y)
        }
        Rectangle {
            id:itemscontent
            anchors.centerIn: parent
            width:parent.width
            color: "transparent"
        }
    }
    

    Thank you.

    Edited: Please surround the code with ``` (3 backticks)

    P 1 Reply Last reply 8 Oct 2015, 06:30
    0
    • A ajvanho6
      7 Oct 2015, 15:31

      Hello i am trying to implement mouse wheel scrolling over Flickable area. Rectangle which is inside Flickable is kind a menu content container. And it holds menu items which number is changing. So i used Flickable to get that container scrolling but it works when you press a mouse and drag but scroll wheel is not working. I tried to put Item element outside flickable and wrap everything up but then flickable is not working.

      Here is the code

      import QtQuick 2.1
      
      Flickable {
          signal drag(string mouseY)
          id: flickable
          contentWidth: itemscontent.width
          contentHeight: 712
          flickableDirection: Flickable.VerticalFlick
          clip: true
          width: parent.width
          interactive: true
          boundsBehavior: Flickable.StopAtBounds
          anchors.fill: parent
      
          MouseArea {
              anchors.fill: parent
              onWheel: flickable.drag(mouse.y)
          }
          Rectangle {
              id:itemscontent
              anchors.centerIn: parent
              width:parent.width
              color: "transparent"
          }
      }
      

      Thank you.

      Edited: Please surround the code with ``` (3 backticks)

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 8 Oct 2015, 06:30 last edited by p3c0 10 Aug 2015, 06:30
      #2

      Hi @ajvanho6 and Welcome
      Flickable will allow flicking on mouse wheel events or otherwise automatically if the contentWidth and contentHeight is greater than it's width and height. You don't have to add a MouseArea explicitly.
      Try following example:

      import QtQuick 2.4
      
      Flickable {
          id: flickable
          clip: true
          width: 200
          height: 480
          contentWidth: itemscontent.width
          contentHeight: itemscontent.height
          boundsBehavior: Flickable.StopAtBounds
      
          Rectangle {
              id:itemscontent
              anchors.centerIn: parent
              width: 100
              height: 680
              color: "red"
              Text {
                  anchors.centerIn: parent
                  text: "MyText"
              }
          }
      }
      

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ajvanho6
        wrote on 8 Oct 2015, 10:31 last edited by
        #3

        Hello @p3c0 thank you for helping. Unfortunately i did try as you suggested but no luck so far. Mouse wheel is not responding it just wok when i press and drag Don't know what could be the issue. I must check other files of my app maybe something is interfering with this file.

        1 Reply Last reply
        0

        2/3

        8 Oct 2015, 06:30

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved