You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, December 30th 2005, 11:04am

How to create a partially transparent window?

Say I had a png image, and I wanted to make a window out it with whatever's behind the window (or the desktop wallpaper) showing through the transparent pixels in the png.

I tried to see how SuperKaramba does it, but don't know enough about the KDE/QT api yet to understand its source code.

I can do it with SDL (given the filename of the desktop wallpaper), but there's got to be a better way. How would you do it with QT?

This post has been edited 1 times, last edit by "StringCheesian" (Dec 30th 2005, 11:04am)


jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

2

Friday, December 30th 2005, 11:22am

RE: How to create a partially transparent window?

Try QWidget::setMask() combined with QPixmap::mask().

3

Friday, December 30th 2005, 11:52am

RE: How to create a partially transparent window?

Quoted

Originally posted by jacek
Try QWidget::setMask() combined with QPixmap::mask().

Thanks, but it looks like that only works for fully transparent and fully opaque pixels... what about pixels that are in-between (like 50% transparent)?

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

4

Friday, December 30th 2005, 12:22pm

RE: How to create a partially transparent window?

Quoted

Originally posted by StringCheesian
Thanks, but it looks like that only works for fully transparent and fully opaque pixels... what about pixels that are in-between (like 50% transparent)?

QWidget::setWindowOpacity() doesn't work under X11 in Qt3, so SuperKaramba must do it some other way, like drawing directly on the desktop or "borrowing" background from it.

5

Friday, December 30th 2005, 11:20pm

Can Qt 4 or 4.1 do it?

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

6

Friday, December 30th 2005, 11:25pm

Quoted

Originally posted by StringCheesian
Can Qt 4 or 4.1 do it?

Quoted

From Qt docs:
windowOpacity : double
This property holds the level of opacity for the window.
The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent).
By default the value of this property is 1.0.
This feature is available on Mac OS X, X11 platforms that support the Composite extension, and Windows 2000 and later.
Note that under X11 you need to have a composite manager running, and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager you are using.

7

Saturday, December 31st 2005, 4:48am

Thanks, I guess that's as close as it gets to what I want.

Now I understand why Konsole uses "fake transparency", because real tranparency isn't avaliable unless you want the whole window to have the same opacity, and making different parts of the window different opacities is just impossible... great ;(.

Stupid X11 X(.