Results 1 to 10 of 10

Thread: How to know the value of a point on the graph?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to know the value of a point on the graph?

    I corrected:

    Qt Code:
    1. picker_m = new QwtPickerClickPointMachine();
    2. picker_m->setState(QwtPickerMachine::PointSelection);
    3. d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    4. QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
    5. myPlot->canvas());
    6. d_picker->setStateMachine(picker_m);
    7.  
    8. connect(d_picker, SIGNAL(selected(const QPointF &pos)), SLOT(UpdVizir()));
    To copy to clipboard, switch view to plain text mode 
    But anyway, nothing has changed.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to know the value of a point on the graph?

    Of course not - how should it work, when you throw away the coordinate of the selected signal and connect it to the same wrong UpdVizir slot.

    Uwe

  3. #3
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to know the value of a point on the graph?

    Could you tell what I need to fix?

    Qt Code:
    1. Object::connect: No such signal QwtPlotPicker::selected(const QPointF &pos)
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void TrendTop::UpdVizir()
    2. {
    3. int cp;
    4. cp = curv1->closestPoint(d_picker->trackerPosition());
    5. psetInterval->setNum(cp);
    6. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to know the value of a point on the graph?

    Quote Originally Posted by oddytz1989 View Post
    Could you tell what I need to fix?
    Sorry I wrote nonsense of course QwtPlotCurve::closestPoint want a point in widget coordinates. You have to write something like this:

    Qt Code:
    1. connect( picker, SIGNAL( selected( const QPolygon & ), SLOT(UpdVizir( const QPolygon & )));
    To copy to clipboard, switch view to plain text mode 
    and

    Qt Code:
    1. void TrendTop::UpdVizir( const QPolygon &points )
    2. {
    3. if ( points.size() != 1 )
    4. return; // should never happen for point selections
    5.  
    6. double dist;
    7. int index = curv1->closestPoint( points[0], &dist );
    8. if ( index >= 0 && dist <= ... )
    9. {
    10. const QPointF found = curv1->sample( index );
    11. ....
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Uwe for this useful post:

    oddytz1989 (14th February 2012)

  6. #5
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to know the value of a point on the graph?

    Biiiiig thanks. The last question. How on the chart when you click the mouse show a vertical line?. I wrote:
    Qt Code:
    1. d_picker->setRubberBandPen(QColor(Qt::green));
    2. d_picker->setRubberBand(QwtPicker::VLineRubberBand);
    To copy to clipboard, switch view to plain text mode 
    But nothing works.

  7. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to know the value of a point on the graph?

    Check the bode example. It uses a crosshair instead of a vertical line - but the rest should be the same.

    Uwe

  8. The following user says thank you to Uwe for this useful post:

    oddytz1989 (15th February 2012)

Similar Threads

  1. Replies: 3
    Last Post: 21st June 2011, 19:37
  2. Replies: 1
    Last Post: 3rd December 2009, 14:23
  3. display a plot point by point
    By oswalidos in forum Newbie
    Replies: 32
    Last Post: 13th March 2009, 15:37
  4. graph
    By sonu111 in forum Qwt
    Replies: 1
    Last Post: 15th December 2008, 22:14
  5. how to paint scene point by point
    By elessaar in forum Qt Programming
    Replies: 8
    Last Post: 4th September 2008, 20:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.