Sonntag, 17. Februar 2008

Running transparent widgets in Qt 4.x on linux systems

After you have set up your xserver with the composite extensions, you are ready for transparent widgets.

Just call the QWidgets setWindowOpacity method and enter a value between 1.0 and 0.0.
The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent).


QWidget *pTestWidget = new QWidget;
pTestWidget->setWindowOpacity(0.5);
pTestWidget->setGeometry(100,100,200,200);
pTestWidget->show();

And now test it and have fun ;)

Transparency with Composite extensions for xorg on Debian Lenny

The first thing we need is to set up our 3D video card. I run a nvidia 8800 gtx with the latest drivers from nvidia. After installing your 3D driver succsessfully you are ready for the composite-extensions for your x.org xserver.

So lets start.
Make sure you have installed the compiz-core packages.

Next we need to modify the /etc/xorg.conf file. I would recommend to make a backup first ;)

We need to enhance some sections of the xorg.conf file to enable the composite extensions.
The first section is the "Extensions" section which where we add the "Composite" option:
Section "Extensions"
Option "Composite" "enable"
EndSection

Then enhance the
"Device" section with the following two options:

Section "Device"
...
...
Option "AllowGLXWithComposite" "true"
Option "RenderAccel" "true"
EndSection

And last but not least we need to enhance the
"Screen" section with these two options:

Section "Screen"
Option "XAANoOffscreenPixmaps"
Option "AddARGBGLXVisuals" "True"
...
...
EndSection




Depending on the window manager you are running you have to enable transparency differently.Take a look in the preferences of your window manager.

I am running Xfce and there you can turn on compisite extension under:

xfce-setting-show > Windowmanager-Tweaks > Tab: Compositor

Xfce on debian lenny:

Xfce is a gtk based desktop enviroment including windowmanager which is very performant and stable. More information can be found at the Xfce site.

If you want to try the Xfce windowmanager you have to install the following packages:
xfce4
xfce4-goodies
gdm
  • xfce4-goodies installs all availables extensions to xfce. All of these extensions can be enabled or disabled separatly.
  • Xfce has no own login manager, so we have to use gdm from gnome.