Hello,

I want to drag my QwtPlotMarker on the plot and thus I have writen the following functions:
Qt Code:
  1. void Plot::cursorSelected(const QwtDoublePoint &Point)
  2. {
  3. std::cout << "in Plot::cursorSelected" << std::endl;
  4. const QwtPlotItemList& List = itemList();
  5. QwtPlotItemIterator Iter = List.begin();
  6.  
  7. selectedPoint = NULL;
  8. std::cout << "selectedPoint = " << selectedPoint << std::endl;
  9. std::cout << "Point = " << Point.x() << ", " << Point.y()<< std::endl;
  10. while(Iter != List.end())
  11. {
  12. QwtPlotItem *pItem = (QwtPlotItem *)(*Iter);
  13.  
  14. if(pItem->rtti() == QwtPlotItem::Rtti_PlotMarker)
  15. if(pItem->boundingRect().contains(Point)){
  16. std::cout << "MATCH" << std::endl;
  17. selectedPoint = dynamic_cast<QwtPlotMarker*>(pItem);
  18. std::cout << "selectedPoint = " << selectedPoint << std::endl;
  19. }
  20. Iter++;
  21. }
  22. }
  23.  
  24. void Plot::cursorMoved( const QPoint& Point){
  25. std::cout << "in Plot::cursorMoved" << std::endl;
  26. if(selectedPoint){
  27. double xData = this->invTransform(selectedPoint->xAxis(), Point.x());;
  28. double yData =this->invTransform(selectedPoint->yAxis(), Point.y());;
  29.  
  30. std::cout << "xData: " << xData <<"yData: " << yData<< std::endl;
  31. selectedPoint->setXValue(xData);
  32. selectedPoint->setYValue(yData);
  33.  
  34. std::cout << "selectedPoint->xValue(): " << selectedPoint->xValue() <<"selectedPoint->yValue(): " << selectedPoint->yValue()<< std::endl;
  35. this->replot();
  36. }
  37. }
To copy to clipboard, switch view to plain text mode 

and I get the following output if I drag the Marker:
in Plot::cursorMoved
xData: 0.38022yData: -0.00858369
selectedPoint->xValue(): 0.38022selectedPoint->yValue(): -0.00858369
in Plot::cursorMoved
xData: 0.410989yData: -0.0343348
selectedPoint->xValue(): 0.410989selectedPoint->yValue(): -0.0343348
in Plot::cursorMoved
xData: 0.481319yData: -0.0772532
selectedPoint->xValue(): 0.481319selectedPoint->yValue(): -0.0772532
in Plot::cursorSelected
selectedPoint = 0
Point = 0.481319, -0.0772532

That means the coordinates of the marker are changed, but the command this->replot() does not work because the marker is still on its last position.
Or does I have to repaint/ redraw the marker at new position by calling its member function "draw"?

Help me please.

Thank you