Results 1 to 4 of 4

Thread: QwtSpectrogram example program

  1. #1
    Join Date
    Jul 2008
    Posts
    2
    Platforms
    Unix/X11

    Default QwtSpectrogram example program

    Greetings,

    I need functionality similar to Matlab's "imagesc" function, but in Qt. I will be filling a 2D matrix with values, where the x and y represent a point and the value represents a magnitude that needs to be displayed as a color based on its value within a range/colormap. This matrix will get filled pretty often (every half second or so), and need to be replotted after it gets filled each time.

    I noticed that QwtSpectrogram may do this for me, but I don't want the contours. I can't get it working at all, however. Is this the class I should be using to plot such a thing, or is there something better or more suiting in the qwt library?

    If someone would be so kind, could a standalone example program be put together that merely fills a 2D array with values and plots it as a spectrogram properly (with a default colormap, but no contours)? An accompanying screenshot would be fantastic as well!

    This would be a great help, and may prove very useful for others searching the forum for such a thing. I can't thank you enough for your help.

    Chris

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

    Default Re: QwtSpectrogram example program

    I will be filling a 2D matrix with values, where the x and y represent a point and the value represents a magnitude that needs to be displayed as a color based on its value within a range/colormap.
    This is exactly, what QwtPlotSpectrogram is intended for.
    I noticed that QwtSpectrogram may do this for me, but I don't want the contours.
    You can display your raster data as image and/or as contour mode - the default is as image only. So if you don't explicitely turn on the contour you don't get one.
    If someone would be so kind, could a standalone example program be put together that merely fills a 2D array with values and plots it as a spectrogram properly (with a default colormap, but no contours)? An accompanying screenshot would be fantastic as well!
    Look at the spectrogram example of Qwt or at the screenshots on the Qwt homepage.

    All you need to do is to derive your own type of QwtRasterData and connect the range and value methods with your 2D array. Note that you need to do some resampling ( in most cases simply a next neighbour ) of your array, because the value method requests values for a raster, that comes from the pixel positions - not from your raster. Also don't forget to implement the copy method, but don't copy your array - only the interface. The easiest way to do so is to use a Qt container ( f.e a QVector ), that implicitely shares your values.

    Uwe

  3. #3
    Join Date
    Jul 2008
    Posts
    2
    Platforms
    Unix/X11

    Default Re: QwtSpectrogram example program

    Thank you for your quick response, Uwe.

    I currently have a large Qt application that does not use anything from the Qwt library. We would like to add a spectrogram plot to this existing application. An obvious first step is to put the Qwt spectrogram example into the existing Qt code (which cannot easily be changed).

    Can this be done easily? Is there a way to do the exact same thing as QwtPlotSpectrogram without having to include Qwt? Sorry for the naive questions, I am still trying to wrap my head around how this can be done within my existing codebase.

    Thanks again for all of your help.

    Chris

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

    Default Re: QwtSpectrogram example program

    Quote Originally Posted by cgifford View Post
    I currently have a large Qt application that does not use anything from the Qwt library. We would like to add a spectrogram plot to this existing application. An obvious first step is to put the Qwt spectrogram example into the existing Qt code (which cannot easily be changed).
    All Qwt widgets are Qt widgets and adding a QwtPlot widget to a Qt application is as easy/difficult as adding a QLabel ( or any other Qt widget ).
    Can this be done easily? Is there a way to do the exact same thing as QwtPlotSpectrogram without having to include Qwt? Sorry for the naive questions, I am still trying to wrap my head around how this can be done within my existing codebase.
    Of course you can implement your own plot widget from scratch. But in the end you have to add it to your application too, what is exactly the same work you have to do with a derived QwtPlot widget.

    Uwe

Similar Threads

  1. Replies: 19
    Last Post: 21st January 2008, 10:13
  2. Replies: 5
    Last Post: 29th October 2007, 23:49
  3. Version setting in QT Program
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 24th October 2007, 13:07
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 05:19
  5. Enter key causing program to exit
    By welby in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 17: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.