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

techsgin techsgin at gmail.com
Wed Feb 18 00:09:53 CET 2009


Hi Henning

We tried it, and it works great many thanks. :)

Just as a comment for others:
We had to use a frameless window (Qt::FramelessWindowHint). 
It seems like a window with a title forces the background.

As for composition it is not required at least on windows xp.

And many thanks again hanning. :)

Regards
TechSgin



-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Henning Burchardt
Sent: Tuesday, February 17, 2009 21:42 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Is possible to use partial window opacity? (i.e.
Leave certain areas Opaque)

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list