Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Can I stop draggable items in a Flickable from stealing Flickable mouse events?
Forum Updated to NodeBB v4.3 + New Features

[Solved] Can I stop draggable items in a Flickable from stealing Flickable mouse events?

Scheduled Pinned Locked Moved QML and Qt Quick
qmlflickabledragging
4 Posts 2 Posters 3.8k Views 2 Watching
  • 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.
  • E Offline
    E Offline
    eLim
    wrote on last edited by eLim
    #1

    Currently I have a Flickable with a Grid in it. The Grid holds a bunch of squares. The Flickable works great here. I can scroll up and down and look at all my squares. But now I want to be able to drag the squares inside of my Flickable.

    So I've added a MouseArea and set the appropriate drag target. Now the squares can be dragged! However the squares seem to steal the mouse events from the Flickable. So the only way to scroll the Flickable is to drag the mouse cursor on the spaces between the squares (very hard!)

    Here is my code:

    Flickable {
        id: flickable
        contentHeight: grid.height
        anchors.fill: parent
    
        Grid {
            id: grid
            width: parent.width
            spacing: 2
    
            Repeater {
                id: repeater
                model: 40
                delegate: tile
            }
        }
    }
    
    Component {
       id: tile
    
       Rectangle {
           id: rect
           width: 128
           height: 128
           color: "black"
    
           MouseArea {
               id: mouseArea
               anchors.fill: parent
               drag.target: rect
           }
       }
    }
    

    Any help is much appreciated. Thanks!

    p3c0P 1 Reply Last reply
    1
    • E eLim

      Currently I have a Flickable with a Grid in it. The Grid holds a bunch of squares. The Flickable works great here. I can scroll up and down and look at all my squares. But now I want to be able to drag the squares inside of my Flickable.

      So I've added a MouseArea and set the appropriate drag target. Now the squares can be dragged! However the squares seem to steal the mouse events from the Flickable. So the only way to scroll the Flickable is to drag the mouse cursor on the spaces between the squares (very hard!)

      Here is my code:

      Flickable {
          id: flickable
          contentHeight: grid.height
          anchors.fill: parent
      
          Grid {
              id: grid
              width: parent.width
              spacing: 2
      
              Repeater {
                  id: repeater
                  model: 40
                  delegate: tile
              }
          }
      }
      
      Component {
         id: tile
      
         Rectangle {
             id: rect
             width: 128
             height: 128
             color: "black"
      
             MouseArea {
                 id: mouseArea
                 anchors.fill: parent
                 drag.target: rect
             }
         }
      }
      

      Any help is much appreciated. Thanks!

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @eLim Make use of pressDelay. In this way the events to its child are delivered after the said time. For eg:

      pressDelay: 1000 //events delivered after 1 sec
      

      Thus normal flicking also works as well as mouse dragging too.

      157

      E 1 Reply Last reply
      2
      • p3c0P p3c0

        @eLim Make use of pressDelay. In this way the events to its child are delivered after the said time. For eg:

        pressDelay: 1000 //events delivered after 1 sec
        

        Thus normal flicking also works as well as mouse dragging too.

        E Offline
        E Offline
        eLim
        wrote on last edited by
        #3

        @p3c0 Thank you very much. This works just fine!

        p3c0P 1 Reply Last reply
        0
        • E eLim

          @p3c0 Thank you very much. This works just fine!

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @eLim You're Welcome :)

          157

          1 Reply Last reply
          0

          • Login

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