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

    @picker->setStateMachine(pickerMachine);@

    -connect picker Signal with a Slot

    @connect(picker,SIGNAL(moved(QPoint)),this,SLOT(function(QPoint)));@

    -your slot function should look like this

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

    ui->qwtPlot->replot();@
    

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.