Results 1 to 3 of 3

Thread: How to draw rectangle over qwtPlotCurve?

  1. #1
    Join Date
    Jun 2008
    Posts
    18
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question How to draw rectangle over qwtPlotCurve?

    Hi,

    Is it possible to draw transparent colored resctangles over qwtPlotCurve(see attached example plot, red curve is the qwtPlotCurve) I'm thinking of drawing histogram and qwtPlotCurve on the same plot, but not sure if it is doable.

    Anybody has a suggestion?

    Thanks in advance!
    Attached Images Attached Images

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

    Default Re: How to draw rectangle over qwtPlotCurve?

    Quote Originally Posted by qmonkey View Post
    I'm thinking of drawing histogram and qwtPlotCurve on the same plot, but not sure if it is doable
    In general you can have as many plot items as you want on a plot, but I recommend to implement a new plot item instead of misusing a histogram:

    Qt Code:
    1. class RangeMarker: public QwtPlotItem
    2. {
    3. public:
    4. RangeMarker()
    5. {
    6. setZ( ... );
    7. }
    8.  
    9. void setInterval( QwtInterval& interval )
    10. {
    11. m_interval = interval;
    12. }
    13.  
    14. virtual void draw( QPainter *painter,
    15. const QwtScaleMap &xMap, const QwtScaleMap &,
    16. const QRectF &canvasRect ) const
    17. {
    18. int x1 = qRound( xMap.transform( m_interval.minValue() ) );
    19. int x2 = qRound( xMap.transform( m_interval.maxValue() );
    20.  
    21. painter->fillRect( QRect( x1, canvasRect.top(), x2 - x1, canvasRect.height() ), ... );
    22. }
    23. };
    To copy to clipboard, switch view to plain text mode 

    HTH,
    Uwe

  3. The following 2 users say thank you to Uwe for this useful post:

    BagpipesJohnson (4th December 2014), qmonkey (9th November 2012)

  4. #3
    Join Date
    Jun 2008
    Posts
    18
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Wink Re: How to draw rectangle over qwtPlotCurve?

    Uwe,

    This is exactly what I needed. I appreciated your time for replying with the code!

Similar Threads

  1. Replies: 1
    Last Post: 1st June 2011, 07:39
  2. How to draw rectangle with moveable edge
    By sagirahmed in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2010, 06:21
  3. Replies: 1
    Last Post: 6th May 2010, 07:25
  4. Replies: 2
    Last Post: 7th July 2009, 07:44
  5. Replies: 2
    Last Post: 14th April 2008, 11:03

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.