Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have draggable items inside of a Flickable while maintaining Flickable functionality?

Tags:

qt

qml

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!

like image 803
elim2g Avatar asked Sep 01 '25 16:09

elim2g


1 Answers

Thanks to this post I was alerted of the Flickable's pressDelay property. This has since solved my issues!

like image 53
elim2g Avatar answered Sep 09 '25 16:09

elim2g