Skip to main content
Zwei.9
Associate III
August 27, 2019
Solved

How to move a curve by mouse movement?

  • August 27, 2019
  • 7 replies
  • 1941 views

I want to implement a function: after the mouse 0690X00000AAJ6UQAX.bmpclick on the curve to be able to drag the curve until the mouse is released

This topic has been closed for replies.
Best answer by Martin KJELDSEN

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

7 replies

Martin KJELDSEN
Principal III
August 27, 2019

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

Zwei.9
Zwei.9Author
Associate III
August 27, 2019

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?