Results 1 to 4 of 4

Thread: setting one value transparent in QwtPlotSpectrogram

  1. #1
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default setting one value transparent in QwtPlotSpectrogram

    Hi all,
    I am using QwtPlotSpectrogram to display two raster 'maps' (great library btw).
    The bottom layer spectrogram is a gray scale shaded relief map of a landscape and the top map is information from a water balance calculation in a blue colors from light blue to darkblue using QwtLinearColorMap. I would like the value 0 of the top layer spectrogram to be totally transparent (alpha = 0) and the blue values to be partially transparent (for instance alpha = 200). This top layer changes every few seconds because a model in a different thread does water balance calculations so the information is renewed every model run and the spectrograms are redrawn:
    - fill a vector with relief data,
    - attach the gray scale colormap
    - replot and rescale the QwtPlot
    - fill a vector with 'water data'
    - attach a blue palette colormap
    - replot and rescale the QwtPlot
    - next model run

    I hope I can make myself clear! I can attach code but its rather a lot. Basically I follow the spectrogram example.

    I have tried setting the alpha value in QwtLinearColorMap but that has no effect and I have tried setAlpha(int) of the QwtPlotSpectrogram but that makes the spectrogram more grayish but not transparent (and is anyway not what I want).
    There is also QwtAlphaColorMap but I don't understand how to link that to the spectrogram or the colormap.

    thanks for any help

    Victor
    Last edited by qt_gotcha; 12th May 2012 at 08:54.

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

    Default Re: setting one value transparent in QwtPlotSpectrogram

    Quote Originally Posted by qt_gotcha View Post
    I would like the value 0 of the top layer spectrogram to be totally transparent (alpha = 0...
    Add a color stop with QColor( Qt::transparent ) at position 0.0 ( or overload QwtLinearColorMap::rgb() ).

    ... and the blue values to be partially transparent (for instance alpha = 200).
    spectrogram->setAlpha( 200 );

    HTH,
    Uwe

  3. The following user says thank you to Uwe for this useful post:

    jose_inesta (23rd May 2012)

  4. #3
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setting one value transparent in QwtPlotSpectrogram

    thanks for helping. it doesn't work yet. I can make certain ranges (semi) transparent but I don't see a the previous plot that is in the same widget, but the background color value, i.e. color1 of the linearcolormap(color1, color2). I'll continue looking

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

    Default Re: setting one value transparent in QwtPlotSpectrogram

    In SVN trunk I have added a slider to the spectrogram example, where you can see how to use the alpha value.

    Uwe

Similar Threads

  1. Google map on QwtPlotSpectrogram
    By sagittager in forum Qwt
    Replies: 4
    Last Post: 15th October 2011, 15:32
  2. Replies: 2
    Last Post: 16th June 2011, 10:56
  3. Replies: 8
    Last Post: 17th April 2011, 17:16
  4. Replies: 0
    Last Post: 25th August 2010, 17:39
  5. Replies: 9
    Last Post: 3rd December 2009, 18:19

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
  •  
Qt is a trademark of The Qt Company.