Results 1 to 4 of 4

Thread: QwtPlotMarker On the Center of the Plot

  1. #1
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QwtPlotMarker On the Center of the Plot

    I am trying to have to two labels in the middle of the QwtPlot.
    ie: plot
    |--------------------------------------|
    | |
    | top center label |
    | |
    | label 2 |
    | |
    |--------------------------------------|
    How can I do that? Thanks.
    HYIP Daily Blog - A must read for all HYIP investors. All HYIP news on the net.

  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: QwtPlotMarker On the Center of the Plot

    Implement a new type of plot item ( derive from QwtPlotItem ). In YourItem::draw use QPainter ::drawText centered to the canvasRect.

    Uwe

  3. #3
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotMarker On the Center of the Plot

    I am a bit confused. When do I call this new myItem::draw method or how do I call this method, like override a new drawCanvas method for myQwtPlot? Thanks.
    HYIP Daily Blog - A must read for all HYIP investors. All HYIP news on the net.

  4. #4
    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: QwtPlotMarker On the Center of the Plot

    Something like this:

    Qt Code:
    1. class TextItem: public QwtPlotItem
    2. {
    3. public:
    4. void setText( const QString &text )
    5. {
    6. m_text = text;
    7. }
    8.  
    9. virtual void draw( QPainter *painter,
    10. const QwtScaleMap &, const QwtScaleMap &,
    11. const QRectF &canvasRect ) const
    12. {
    13. painter->drawText( canvasRect, Qt::AlignCenter, m_text );
    14. }
    15.  
    16. private:
    17. QString m_text;
    18. };
    To copy to clipboard, switch view to plain text mode 

    Attach this item to your plot like a curve and the draw method will be part of the plot image composition.

    Uwe

Similar Threads

  1. Replies: 6
    Last Post: 7th January 2013, 16:30
  2. QwtPlotMarker example
    By banita in forum Qwt
    Replies: 1
    Last Post: 24th May 2012, 13:19
  3. Replies: 5
    Last Post: 11th January 2011, 06:37
  4. QwtPlotMarker segfault
    By viridis in forum Qwt
    Replies: 4
    Last Post: 17th September 2008, 13:22
  5. QwtPlotMarker confusion
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 20th July 2008, 09:47

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.