Sections

How can I draw shadows behind windows ?

 

Answer:

This functionality is not supported in the Qt API yet and would therefore have to be done using native system calls. The function you are looking for in the Win32 API is called UpdateLayeredWindow():

http://msdn2.microsoft.com/en-us/library/ms633556.aspx

It requires that you first create a layered window as mentioned in the above documentation. Something similar can be achieved on X11 using an ARGB visual. We have an example of this in our "Graphics Dojo":

 

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

 
We plan on implementing support for this in the future:

http://trolltech.com/developer/task-tracker/index_html?method=entry&id=162697

There are other solutions you can use for "faking" this effect for windows of a static size (useful for splash screens). For instance, you can take a screenshot of the desktop widget using the following code snippet:

 

QSize SIZE(600, 300);

QRect splashScreenRect(r.width() / 2 - SIZE.width() / 2,
                                     r.height() / 2 - SIZE.height() / 2,
                                     SIZE.width(), SIZE.height());

QPixmap desktopBg = QPixmap::grabWindow(
                                       QApplication::desktop()->winId(),
                                       splashScreenRect.x(),
                                       splashScreenRect.y(),
                                       splashScreenRect.width(),
                                       splashScreenRect.height());

 

Then you would just draw this pixmap as normal and paint using alpha blending on top of it. We use this technique for the splash screen in our Qt Jambi product.

back

Patron of KDECustomers

Customers