Results 1 to 2 of 2

Thread: Getting the the curser position in plot coordinates after specific interval

  1. #1
    Join Date
    Jun 2013
    Posts
    3
    Platforms
    Windows

    Default Getting the the curser position in plot coordinates after specific interval

    Hello,

    I am developing an application using qwtplot to continuiously take the coordinates from the curser position and then plot the amplitude of the sine curve.

    T get the cursor position, I am using :

    QCursor *mycurser = new QCursor;
    pos_global = mycurser->pos();
    pos_local = this->mapFromGlobal(pos_global);

    Pos_local gives me the coordinates in integers, I dont know if they are called pixel coordinates. I wanted to get the coordinates with reference to myplot, so thats why I used following function:
    QPointF plot::myinvTransform( const QPoint &pos ) const
    {
    QwtScaleMap xMap = this->canvasMap( this->xBottom );
    QwtScaleMap yMap = this->canvasMap( this->yLeft );

    return QPointF(
    xMap.invTransform( pos.x() ),
    yMap.invTransform( pos.y() )

    );
    }
    and I call the function after specific interval with my curserposition as:

    QPoint pointPlot = myinvTransform( pos_local);
    I am getting the mapped coordinates but they are not accurate. There is a little offset in both the x and y positions.

    Anyone have any idea please help me. Or if you don;t understand my problem, just ask me, i will reply very fast.

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

    Default Re: Getting the the curser position in plot coordinates after specific interval

    Widget coordinates are in integers and because of this mapping a plot coordinate into widget coordinates is not reversible without rounding errors.

    Uwe

    PS: the curvetracker example might be related

Similar Threads

  1. How to show dockWidget at specific position in Qt?
    By gurmeetsingh in forum Qt Programming
    Replies: 0
    Last Post: 26th July 2012, 07:12
  2. Qwt How to plot our specific symbols?
    By sonulohani in forum Newbie
    Replies: 3
    Last Post: 28th May 2012, 07:48
  3. Replies: 3
    Last Post: 8th February 2012, 01:57
  4. Replies: 10
    Last Post: 21st September 2011, 08:03
  5. Replies: 10
    Last Post: 17th May 2011, 09:47

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.