PDA

View Full Version : transparent background of the main widget



nagpalma
27th April 2007, 17:41
Hi ,

The widget in the "analogclock" example is transparent with respect with my widget. But, how can i make my widget transparent with respect with my desktop? (My widget is the base widget for all the other widget including the widget in the "analogclock").

I tryed to alter the widget's default palette with:


QPalette p(palette());
p.setColor ( QPalette::Window, Qt::transparent);
setPalette(p);
but instead of a transparent background i got a black background !

I don't understand what happened.

Please, help me.

Regards,
Nuno

Bitto
29th April 2007, 09:25
Qt doesn't support this very well, because it doesn't work reliably on all platforms. On X11, you need the XComposite and XRender extensions for semitransparent windows, which is only supported in the very newest X servers, and it's most often disabled by default because of driver problems.

Zack has got an example on his Dojo pages on Trolltech Labs that shows how you can make this work:

http://labs.trolltech.com/page/Graphics/Examples/Examples1

For your case, maybe you could just use a mask. You could capture child events for your top-level window, and set a custom mask based on the union of the regions of all immediate children...

nagpalma
4th May 2007, 17:52
Thanks Bitto for your advices.
I'll try to configure X11 and then i'll give notices....

Regards,
Nuno