2019-08-26 10:41 PM
I want to implement a function: after the mouse click on the curve to be able to drag the curve until the mouse is released
Solved! Go to Solution.
2019-08-27 05:11 AM
Forgot to mention. In your call to moveTo(x,y) you would ofcourse juse use the current y-coordinate of the graph so that you don't move the graph accidentally in the y axis, but only in the x axis.
And consider relative coordinates and consider edges, so, actually, you would use deltaX - Forget what i said earlier.
graph.moveTo(deltaX, graph.getY());
Because deltaX can be negative.
/Martin
2019-08-27 12:20 AM
Hi @Zwei.9,
Just override handleDragEvent() in your view and use deltaX argument of the drag event to move your graph. This will work using your mouse in the simulator.
/Martin
2019-08-27 01:32 AM
Hello.@Martin KJELDSEN
I overrided handleDragEvent() in my view.
void MainWindowView::handleDragEvent(const DragEvent& evt)
{
graph.moeTo(20+evt.getDeltaX(),20+evt.getDeltaY());
}
When I run it and drag the curve, it wobbles a lot.What's the reason?
2019-08-27 03:38 AM
Maybe we implemented wobbly behavior in Graph::moeTo(). Or did you mean moveTo()? =)
You're not supposed to use the coordinates like that. You actually just have to use newX and newY without the offset (20). The delta is just for your inspection if you need it for anything.
The delta is how far you've moved your finger since last tick.
/Martin
2019-08-27 04:31 AM
Thank you very much!
2019-08-27 05:11 AM
Forgot to mention. In your call to moveTo(x,y) you would ofcourse juse use the current y-coordinate of the graph so that you don't move the graph accidentally in the y axis, but only in the x axis.
And consider relative coordinates and consider edges, so, actually, you would use deltaX - Forget what i said earlier.
graph.moveTo(deltaX, graph.getY());
Because deltaX can be negative.
/Martin
2019-08-27 05:23 AM
Pretty good!Thank you very much!You are my lucky star!
2019-08-28 03:59 AM
Great, no problem! :)