Results 1 to 18 of 18

Thread: mouse tracking showing float numbers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouse tracking showing float numbers

    Do you call the QwtPicker::setEnabled( true ) method anywhere?

  2. #2
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: mouse tracking showing float numbers

    yes,I have an "enablePickerMode" button, which enables/disables the picker.
    When I press it I can see that the picker works fine,
    i can select a polygon and I can see the plot values (but the float number like e-12 are represented as 0.0000 and the trackerText function is never called)

    Qt Code:
    1. void my2dPlot::enablePickerMode(bool on)
    2. {
    3.  
    4. d_picker->setEnabled(on);
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mouse tracking showing float numbers

    which version of qwt are you using? I have 5.2. Maybe something has changed in 6.0. have a look into the sources of qwtplotpicker.h to and check the declaration of TrackerText()...

  4. #4
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: mouse tracking showing float numbers

    I use the QWT Release 6.0.

    searching in my QWT folder i found this in the qwt_plot_picker.cpp


    Qt Code:
    1. QwtText QwtPlotPicker::trackerText( const QPoint &pos ) const
    2. {
    3. return trackerTextF( invTransform( pos ) );
    4. }
    5.  
    6. /*!
    7.   \brief Translate a position into a position string
    8.  
    9.   In case of HLineRubberBand the label is the value of the
    10.   y position, in case of VLineRubberBand the value of the x position.
    11.   Otherwise the label contains x and y position separated by a ',' .
    12.  
    13.   The format for the double to string conversion is "%.4f".
    14.  
    15.   \param pos Position
    16.   \return Position string
    17. */
    18. QwtText QwtPlotPicker::trackerTextF( const QPointF &pos ) const
    19. {
    20. QString text;
    21.  
    22. switch ( rubberBand() )
    23. {
    24. case HLineRubberBand:
    25. text.sprintf( "%.4f", pos.y() );
    26. break;
    27. case VLineRubberBand:
    28. text.sprintf( "%.4f", pos.x() );
    29. break;
    30. default:
    31. text.sprintf( "%.4f, %.4f", pos.x(), pos.y() );
    32. }
    33. return QwtText( text );
    34. }
    To copy to clipboard, switch view to plain text mode 

    is there an obvious reason I cannot overload these functions? should I just go manually and change them?!


    Added after 15 minutes:


    I FOUND IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Ι should overload the trackerTextF function and not the trackerText!!!
    I realized it when I saw the source code of the qwt_plot_picker
    Last edited by fatecasino; 1st February 2011 at 20:24.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: mouse tracking showing float numbers

    I use the QWT Release 6.0.
    Oh boy. Another "gotcha" when moving from Qwt 5.x to 6.0. I hope these kinds of things are going to be documented...

    Sorry fatecasino, all of our answers were based on Qwt 5.2, where your trackerText() code should have worked perfectly.

Similar Threads

  1. tracking mouse coordinates
    By lightning2911 in forum Newbie
    Replies: 8
    Last Post: 11th December 2011, 23:51
  2. mouse tracking on image
    By vermarajeev in forum Qt Programming
    Replies: 14
    Last Post: 12th May 2010, 13:06
  3. Replies: 14
    Last Post: 16th March 2009, 09:19
  4. mouse tracking in QGraphicsItem
    By christina123y in forum Qt Programming
    Replies: 10
    Last Post: 9th March 2009, 08:23
  5. [QT3+XP] transparency and mouse tracking
    By incapacitant in forum Newbie
    Replies: 9
    Last Post: 17th February 2006, 18:49

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
  •  
Qt is a trademark of The Qt Company.