Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
DanBoSlice last edited by
so I am currently working on a nice little app and need some help. In the app there is a grid where the user can create widgets at any position. If a user created a widget I want him to be able to drag the widget to another position in the grid.
Actually its all working perfectly fine with the following code, except a little thing that is bothering me.
With that code the widget can be moved in a way that it does not align with the grid anymore. To fix that, the user should be only able to move the widget for a certain amount of pixels (e.g. when the widget is moved to the left, it does instantly move 100px to the left, if it gets dragged even further 200px .. 300px ....)
Is there any possibility to do this?
One way I think would be to check the threshold for eg. here a value for
onXChanged: if( x < -2) x = -100