[PyQt] QSplashScreen with transparent background

David Boddie david at boddie.org.uk
Tue Mar 24 01:05:34 GMT 2009


On Tue Mar 24 00:18:54 GMT 2009, Saúl Ibarra wrote:
 
> I'm sure this question has been answered many times, but I'm not able
> to achieve what I want :-/ I just want a splashscreen with a single
> png with transparent background.

Is this on Linux/Unix?

> I'm using the following code:
>
> pic = QtGui.QPixmap(":splash/images/splash.png")
> splash = QtGui.QSplashScreen(pic)
> splash.show()
>
> I know the issue has to do with the alpha channel, but can't get it
> working...

On some platforms, there are issues with the display system. This is covered
in the "Translucent Widgets in Qt" article in the latest Qt Quarterly:

  http://doc.trolltech.com/qq/

Basically, you need to be running a compositing window manager. More details
can be found here:

  http://doc.trolltech.com/4.5/qwidget.html#windowOpacity-prop

If you can't guarantee that users will have systems with this feature
enabled, you can always fall back to an approach where you fake a transparent
background. This is done by grabbing the screen with QDesktopWidget the way
the Screenshot example does, then drawing on it and cutting out the part you
want to display.

I believe this is way the Qt Jambi demo launcher does it, though it also does
some fancy things like blurring the background image.

David



More information about the PyQt mailing list