Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qwt movable Plot-markers
QtWS25 Last Chance

Qwt movable Plot-markers

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 6.1k Views
  • 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 Offline
    T Offline
    TrooperDaTom
    wrote on last edited by
    #1

    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
    0
    • U Offline
      U Offline
      uwer
      wrote on last edited by
      #2

      Maybe the Qwt example you find in playgound/curvetracker ?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TrooperDaTom
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved