Important: Please read the Qt Code of Conduct -

Qwt movable Plot-markers

  • Hi everybody,

    i have to write a program for my study in germany.
    In this project i need two movable plot markers in my plot which are moving along the curve.

    They shall work like this:

    when i am clicking at one of them and moving my mouse, the marker follows the mouse right and left and the marker goes along my plot curve.

    Did anyone of you programm something like that already or has some hints for me?

    Thank you!

  • Maybe the Qwt example you find in playgound/curvetracker ?

  • Hey everybody,

    after a few days working at it, i have found one solution for my problem.

    I will list some things quickly!

    -first you have to add an QwtPlotPicker to your QwtPlot

    @QwtPlotPicker *picker = new QwtPlotPicker(ui->qwtPlot->xBottom, ui->qwtPlot->yLeft, QwtPicker::NoRubberBand, QwtPicker::AlwaysOn, ui->qwtPlot->canvas());@

    -than u declare a QwtPickerMachine(ClickPoint or Drag Point)

    @QwtPickerMachine* pickerMachine = new QwtPickerDragPointMachine();@

    -set the PickerMachine to your Picker


    -connect picker Signal with a Slot


    -your slot function should look like this

    @void function(QPoint actualMousePosition){
    int x = myCurve->closestPoint(actualMousePosition,
    QPointF Position = myCurve->sample(x);


    Be sure u declared a QwtPlotMarker before using the function. The Function closestPoint() is very importend.

    I hope i could give u an idea how to use this things, if u have questions write me a private message!

Log in to reply