Now, I'm drawing the QwtPlotMarker on QwtPlot taking user input values from the spinbox. But I want to adjust the position of QwtMarker on mouse click & drag and place it in the required position(Y-Axis). How can I implement this?
Thank you.
Now, I'm drawing the QwtPlotMarker on QwtPlot taking user input values from the spinbox. But I want to adjust the position of QwtMarker on mouse click & drag and place it in the required position(Y-Axis). How can I implement this?
Thank you.
You can do it in several different ways.
In general, you want to install event filter on the plot's canvas to be able to intercept mouse move/button events.
Then on click you need to find which (if any) marker is there at the position of mouse press.
When you have a marker you can then adjust its value during mouse move (you need to replot the plot each time you change marker value to see it move).
If replotting is time consuming, instead of moving actual marker, create a widget that will look like marker and parent it to the canvas.
This widget should be hidden when not dragged.
On mouse press hide actual marker, show the widget (remember to replot after hidding the marker).
On mouse move move the widget.
On mouse release hide the widget, set new value on the marker and show it (remember to replot).
hey, you have already plotted that curve, so now Symbol by the click of mouse, for that use---->
initialize this
Qt Code:
mark[i]->setSymbol(your_symbol); mark[i]->setValue(pt.x(),pt.y()); mark[i]->attach(your_plot); i++; }To copy to clipboard, switch view to plain text mode
Now wherever you click on the curve it will plot it.
rawfool (8th June 2012)
Bookmarks