Results 1 to 6 of 6

Thread: QwtPlot legend with axis

  1. #1
    Join Date
    Jan 2012
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QwtPlot legend with axis

    Hello,

    I'm writing a Qt code using Qwt to represent some signals like in a EEG
    I want do something like in this link

    Now I represent the signals one above the other but I need represent a kind of legend with the voltage scale (like in the last link)

    Any idea?

    are there a qwt widget that I can use to do that?

    Thanks in advance

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

    Default Re: QwtPlot legend with axis

    What about modifying the tick labels of the left scale ?

    Use QwtPlot::setAxisScaleDiv to have major ticks at the positions, where you want to have your labels. Next derive from QwtScaleDraw and reimplement QwtScaleDraw::label() to return the special strings.

    Uwe

  3. #3
    Join Date
    Jan 2012
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot legend with axis

    I modified the left scale to write the names of each wave,
    What I'd like to do is the floating legend with the microvolts and time scale,
    maybe adding a widget that I can move through the QwtPlot dragging it or clicking in the graph.

    thank you

  4. #4
    Join Date
    Jan 2012
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot legend with axis



    I think I found a solution:

    class QwtPlotWithScale: public QwtPlot
    {
    void drawCanvas(QPainter *p)
    {
    this->QwtPlot::drawCanvas(p);
    p->save();
    p->setPen(Qt::blue);
    double x = this->transform(QwtPlot::xBottom,50);
    double y = this->transform(QwtPlot::yLeft,0.5);
    double xx = this->transform(QwtPlot::xBottom,75);
    double yy = this->transform(QwtPlot::yLeft,1);
    p->drawRect(x,y,xx-x,yy-y);
    p->restore();
    }
    };


    that is not the final solution but is the first approximation,
    thank you
    and kind regards

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

    Default Re: QwtPlot legend with axis

    Quote Originally Posted by desantossierra View Post
    I think I found a solution:
    But not a good one - your code will be on screen only, not when using QwtPlotRenderer to generate documents.

    You can do the same in QwtPlotWithScale::drawItems instead - or even better implement a small QwtPlotItem where you render your legend.
    Check the examples - there are several simple plot items implemented.

    Uwe

  6. #6
    Join Date
    Jan 2012
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot legend with axis

    uops

    Ok,
    thank you, I'll try the last one with QwtPlotItem.


Similar Threads

  1. Replies: 2
    Last Post: 30th December 2010, 17:32
  2. QwtPlot fixed X-axis display
    By micc13 in forum Qwt
    Replies: 2
    Last Post: 3rd December 2010, 12:28
  3. Replies: 1
    Last Post: 8th April 2010, 19:25
  4. Replies: 2
    Last Post: 27th October 2009, 13:40
  5. Replies: 2
    Last Post: 5th December 2008, 20: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.