Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qwt movable Plot-markers

    Tools
    2
    3
    5491
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TrooperDaTom last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • U
        uwer last edited by

        Maybe the Qwt example you find in playgound/curvetracker ?

        1 Reply Last reply Reply Quote 0
        • T
          TrooperDaTom last edited by

          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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post