Results 1 to 7 of 7

Thread: qwtplot and mouse tracking

Hybrid View

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

    Default Re: qwtplot and mouse tracking

    got it I had to write my own subclass of QwtPlotPicker and overriding the "trackerText" method:

    Qt Code:
    1. class MyPicker : public QwtPlotPicker
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MyPicker(int xAxis, int yAxis, int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QwtPlotCanvas* canvas);
    7.  
    8. signals:
    9. void mouseMoved(const QPoint& pos) const;
    10.  
    11. protected:
    12. virtual QwtText trackerText (const QwtDoublePoint & pos) const;
    13.  
    14. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. MyPicker::MyPicker(int xAxis, int yAxis, int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QwtPlotCanvas* canvas)
    2. : QwtPlotPicker(xAxis, yAxis, selectionFlags, rubberBand, trackerMode, canvas)
    3. {}
    4.  
    5. QwtText MyPicker::trackerText (const QwtDoublePoint & pos) const
    6. {
    7. const QPoint point = pos.toPoint();
    8. emit mouseMoved(point);
    9. return QwtText(QString::number(point.x()) + ", " + QString::number(point.y()));
    10. }
    To copy to clipboard, switch view to plain text mode 

    now I can react to the "mouseMoved"-signal

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

    Default Re: qwtplot and mouse tracking

    I'm not sure if this is related to QwtPlotPicker or general to Qt...

    as written above, I want to react to the mouseMoved-signal. Currently, I write text into the statusBar. But I want to do this only as long as the mouse is on my plot. When the user moves the mouse outside the canvas, I don't want to do anything. Is there a possibility to check if the cursor is on the canvas? Or the get a signal when the cursor has left the canvas?

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. Mouse tracking outside the application interface
    By sophister in forum Qt Programming
    Replies: 7
    Last Post: 2nd May 2009, 06:44
  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

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.