Results 1 to 2 of 2

Thread: how to get the (x, f(x)) values under the cursor?

  1. #1
    Join Date
    Sep 2008
    Location
    Slovakia, Nitra
    Posts
    15
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how to get the (x, f(x)) values under the cursor?

    Hi,

    I have a QwtPlot. I'd like to get the value of point under the mouse cursor. Yet I can recieve the coordinates:
    Qt Code:
    1. QwtPicker *picker = new QwtPicker(this);
    2. picker->setTrackerMode(QwtPicker::AlwaysOn);
    To copy to clipboard, switch view to plain text mode 

    ,but how can I get the value of x and f(x), also how should I convert coordinates to values, and vice versa?

    Furthermore, how could I insert text to the QwtPlot, because I want put the values next to the points.

    Please, insert short example code, since I'm absolute beginner...
    Thank's in advance.

  2. #2
    Join Date
    Mar 2009
    Location
    Russia
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get the (x, f(x)) values under the cursor?

    There's the method <int QwtPlotCurve::closestPoint(const QPoint &pos, double *dist)>.
    It returns index of the point, and you can call curve.x(index) and curve.y(index) to find x and y.
    You can see the qwt example <event_filter>, file <canvaspicker.cpp>, method <void CanvasPicker::select(const QPoint &pos)> for one of the possible implementations.

  3. The following user says thank you to GNU/Varan for this useful post:

    Carlton (21st April 2009)

Similar Threads

  1. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  2. QListView: How to move the cursor to a specific row
    By muellerp in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2008, 07:29
  3. Is it possible to change the cursor on a QGraphicsView?
    By draftpunk in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2008, 18:43
  4. Trouble with cursor and selecting text in QTextEdit
    By R_Torsten in forum Qt Programming
    Replies: 3
    Last Post: 7th June 2008, 19:17
  5. Cursor not changing
    By bpetty in forum Newbie
    Replies: 4
    Last Post: 17th July 2007, 15:13

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.