Remove delay in QML element movement
-
Rectangle { id: redBox width: 50; height: 50 color: "black" border.width: 4 border.color: "red" } MouseArea { anchors.fill: parent hoverEnabled: true onPositionChanged: (mouse)=> { redBox.x = mouse.x - redBox.width/2 redBox.y = mouse.y - redBox.height/2 } } }
What to change so that when mouse movement is very fast
redBox
follows it at that speed?
When mouse movements is very fast, there's a little delay until theredBox
reaches the mouse position. -
Rectangle { id: redBox width: 50; height: 50 color: "black" border.width: 4 border.color: "red" } MouseArea { anchors.fill: parent hoverEnabled: true onPositionChanged: (mouse)=> { redBox.x = mouse.x - redBox.width/2 redBox.y = mouse.y - redBox.height/2 } } }
What to change so that when mouse movement is very fast
redBox
follows it at that speed?
When mouse movements is very fast, there's a little delay until theredBox
reaches the mouse position. -
Shouldn't I use PropertyAction?
PropertyAction - Specifies immediate property changes during animation
@qcoderpro I feel like you may need a timer to reduce the number of updates of redBox.x and redBox.y if the mouse moves too fast. This means you skip some position changes of mouse.