Results 1 to 3 of 3

Thread: Showing small axis legend in QwtPlot

  1. #1
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Showing small axis legend in QwtPlot

    Hi all,

    I would like to show a small arrows pointing to +ve x and y directions inside the Qwt plotting area. I am already using Qwt axis with scales on them without any problem. Just for usability, it will be very useful to have a 90-degree small arrows corresponding to +ve x and y directions. This would be static at a corner of the plotting area and shouldn't pan or zoom with the plot.

    What would be the appropriate way for drawing this ?

    Thanks

  2. #2
    Join Date
    Dec 2013
    Location
    Toronto, Canada
    Posts
    62
    Thanked 16 Times in 15 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Showing small axis legend in QwtPlot

    subclass QwtPlotItem and re-define draw()

    Something like this ...


    class RefArrow: public QwtPlotItem
    {
    public:
    explicit RefArrow(){}
    virtual ~RefArrow(){}

    void draw( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect ) const
    {
    QLineF vline(20, canvasRect.height()-20, 20, canvasRect.height()-80);
    QLineF hline(20, canvasRect.height()-20, 100, canvasRect.height()-20);
    painter->save();
    QPen p(Qt::red, 3);
    painter->setPen(p);
    painter->drawLine(vline);
    painter->drawLine(hline);
    painter->restore();
    }
    };
    Then ...

    Qt Code:
    1. ....
    2.  
    3. RefArrow * refArrow = new RefArrow;
    4. refArrow->attach(plot);
    5. ...
    To copy to clipboard, switch view to plain text mode 

    This should give lines at 90 degrees and parallel to the axes.
    It should be easy to add arrows

    The stockchart example shows how one can implement there own PlotItems

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

    ahisham (25th February 2014), Momergil (21st May 2014)

  4. #3
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Showing small axis legend in QwtPlot

    Perfect .. Exactly what I am looking for

    Thanks

Similar Threads

  1. qwtPlot legend font size
    By Narciso in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2012, 10:51
  2. QwtPlot legend with axis
    By desantossierra in forum Qwt
    Replies: 5
    Last Post: 20th January 2012, 15:05
  3. Replies: 1
    Last Post: 8th April 2010, 20:25
  4. Replies: 2
    Last Post: 27th October 2009, 14:40
  5. Replies: 2
    Last Post: 5th December 2008, 21:11

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.