Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QGraphicsView - move item by non linear value...
Dariusz last edited by
Right now the item is being moved to the mouse position.
I would like a way to multiply the amount of mouse movement... say if I have a multiplier of 0.5, then move of 100 pixels in mouse distance would result in item moving by 50 pixels...
Does qt offer any way of doing this?
AFAIK, not directly (but I may be wrong though)
Can you explain your use case ? It sounds strange to me that if I move an object with my mouse that it only moves half-way.
Dariusz last edited by Dariusz
@SGaist Its about precision moves, if user wants to move by tiny bit, scaling mouse movement by x value would allow that to happen. Else he would have to type 0.0001 0.0002 0.0003 etc etc.
I think I could handle it using itemChange() and record initial mouse click press/release and calculate delta using that..
Yep that seem to do the trick... I can now move my items by tiny amount and doing "Long precise drags"
deltaX = (newPos.x() - self.mMousePressPosition.x()) / 2 newPos.setX(newPos.x() - deltaX) deltaY = (newPos.y() - self.mMousePressPosition.y()) / 2 newPos.setY(newPos.y() - deltaY)
Small edit, function above works for "simple" items, but as soon as I get to child items with parent it appear to break... sigh. Needs some more math there