Results 1 to 3 of 3

Thread: Need help formatting plot axis

  1. #1
    Join Date
    Mar 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Need help formatting plot axis

    Hey all, I'm relatively new to Qt/Qwt and have a little experience with C++. I've written a program that has a spectrogram plot in it. I got the spectrogram to display my data properly, but the y-axis is in units of Hertz and I want to display it in Khz. I know I need to reimplement the QwtScaleDraw class but I am at a loss as to how it is done, can anybody explain the process to me? Thanks in advance.

  2. #2
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need help formatting plot axis

    Check this example !

    http://www.qtcentre.org/threads/1017...nd-custom-axis

    put a debug line on 'label' method and you'll see what is going on.

  3. #3
    Join Date
    Mar 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Need help formatting plot axis

    I got it to work, thanks for pointing me in the right direction! For anyone who's curious here's the code for the class declaration:
    Qt Code:
    1. class hertz : public QwtScaleDraw
    2. {
    3. public:
    4. hertz(){}
    5. virtual QwtText label(double v) const;
    6. };
    To copy to clipboard, switch view to plain text mode 

    I nested the hertz() class within another class (spectrogram), here's the code for the implementation:
    Qt Code:
    1. QwtText spectrogram::hertz::label(double v) const{
    2. if(v >= 1000 || v <= -1000)
    3. return QString::number(v/1000.0);
    4. else
    5. return QString::number(v);
    6. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Put plot axis out of the plot
    By KosyakOFF in forum Qwt
    Replies: 7
    Last Post: 21st June 2013, 13:36
  2. Replies: 9
    Last Post: 3rd May 2011, 21:21
  3. x-axis for waterfall plot
    By janK in forum Qwt
    Replies: 8
    Last Post: 29th July 2009, 15:00
  4. qwp plot axis scale
    By Cal in forum Qwt
    Replies: 1
    Last Post: 11th May 2009, 17:10
  5. Detecting changes in the qwt plot axis
    By mrcolin in forum Qwt
    Replies: 2
    Last Post: 27th January 2009, 12:53

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.