Kinetic Motion with Deceleration

  • Quick 2.1. Basically what I'd like to do is have a collection of Rectangles in a window that have kinetic motion properties. Each of these is independently draggable via a mouse click / touch on both X and Y. When the object is released, is continues to glide and decelerates.

    I can kind of get this with a Flickable area, and setting:

    boundsBehavior: Flickable.DragAndOvershootBounds

    But, the Flickable needs to cover the entire parent window size, and takes mouse events from anywhere in its bounds, not just the Rectangle it contains. You can click on empty space outside of the Rectangle and still drag it around. Also other Rectangles in their own Flickables are inaccessible because all input is being received by one.

    Anyone have any good ideas for this?


  • Probably best to use a physics library, if you're dealing with a large collection of rectangles. Something like for example.

    If you want to do it manually, you can write custom deceleration animations on the x/y properties proportional to the horizontal/vertical components of the vector of movement at the time of mouse-button release, I guess. You may have to collect mouse (or touch) event data over time to do the vector calculation, though, I'm not sure.


  • My first try was to poke around at Flickables, but these don't quick work that way.

    For the time being I've gone with the deceleration animations. It's not ideal, but it's simple and good enough so far.

    Box2D does look like the ideal. My understanding is that this is Quick 1.0 for the time being though and I'd like to stay in 2.0. In the end this is really the direction I want to go though.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.