Results 1 to 2 of 2

Thread: Need to implement 2 grabbable cursors(markers)

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Need to implement 2 grabbable cursors(markers)

    I will be needing to implement 2 cursors (markers) in my graph. One should be able to grab
    and move each of the 2 cursors with a deltaX, deltaY being displayed somewhere that
    shows the difference between cursor1 and cursor 2.

    This seems like functionality that someone would have already done, so before I start to reinvent the wheel, are there any examples of similar functionality out there?

    If not any suggestions on how to best approach it?

    Thank you.

    Mark

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

    Default Re: Need to implement 2 grabbable cursors(markers)

    Something like this ?

    Qt Code:
    1. class DistancePicker : public QwtPlotPicker
    2. {
    3. public:
    4. DistancePicker( QwtPlotCanvas*);
    5.  
    6. protected:
    7. virtual void drawRubberBand(QPainter*) const;
    8. virtual QwtText trackerText(const QwtDoublePoint& pos) const;
    9. };
    10.  
    11. DistancePicker::DistancePicker(QwtPlotCanvas* canvas):
    12. QwtPlotPicker(canvas),
    13. {
    14. /*
    15.   We don't have a picker for a line, but the rectangle
    16.   selection is also selection of 2 points, so all we
    17.   have to do is to change the rubberband.
    18.   */
    19. setSelectionFlags(QwtPicker::RectSelection);
    20. setRubberBand(PolygonRubberBand);
    21. setTrackerMode(QwtPicker::ActiveOnly);
    22. }
    23.  
    24. void DistancePicker::drawRubberBand(QPainter *painter) const
    25. {
    26. painter->drawPolygon(selection());
    27. }
    28.  
    29. QwtText DistancePicker::trackerText(const QwtDoublePoint &pos) const
    30. {
    31. QwtText text( " selection() as distance string " );
    32.  
    33. QColor bg(Qt::white);
    34. bg.setAlpha(180);
    35. text.setBackgroundBrush(QBrush(bg));
    36. return text;
    37. }
    To copy to clipboard, switch view to plain text mode 

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.