[Qt-interest] Is possible to use partial window opacity? (i.e. Leave certain areas Opaque)

Henning Burchardt hb7d9 at fastmail.fm
Tue Feb 17 20:41:34 CET 2009


Hi,

it is possible, but only in certain circumstances. Under X11, a 
composite manager has to be active and the QApplication object has to be 
constructed in a special manner (see for example the example at 
http://zrusin.blogspot.com/2006/10/argb-windows.html).

For windows with partial window opacity, first 
setAttribute(Qt::WA_NoSystemBackground) has to be called. Then, in 
paintEvent(), a transparent background for the window can be set by calling

    painter.save();
    painter.setCompositionMode(QPainter::CompositionMode_Source);
    painter.fillRect(0, 0, w, h, Qt::transparent);
    painter.restore();

After that, the window can be painted with each pixel having a different 
opacity level.

Hope this helps,
Henning

techsgin wrote:
> Hi All
> 
>  
> 
> Is possible to use partial window opacity? (i.e. Leave certain areas Opaque)
> 
>  
> 
> We are trying to make a semi-transparent window where we show an image which
> is opaque at the middle. 
> 
> * (Like the full screen mode in picasa).
> 
>  
> 
> We are using "setWindowOpacity ( 0.5 )" but this applies to the entire
> window, and we cannot isolate the child widget that display the image.
> 
>  
> 
> Any ideas?
> 
>  
> 
> We had in mind may be to float an extra frameless child window on to of the
> semi-transparent one? But it sounds like the wrong way.
> 
>  
> 
> Thanks
> 
> TechSgin



More information about the Qt-interest-old mailing list