PDA

View Full Version : Transparent dialog widget



girishgowda
1st July 2010, 09:20
Hi all,

I am working on Qt 4.6.2 for Symbian.
I am trying to make a dialog transparent.
I have tried the following:
1. example at http://wiki.forum.nokia.com/index.php/Transparent_QDialog_and_QListWidget_in_Qt - setting attribute Qt::WA_NoSystemBackground
2. Drawing a bitmap and its mask to the dialog
3. setAttribute(Qt::WA_TranslucentBackground, true)

But none of these options seems to make the dialog transparent.

My understanding is that the dialog is a window owning control and this window is not able to be transparent.

If anybody has tried such a thing and has a different understanding or has achieved this please let me know.

Regards
Girish

high_flyer
1st July 2010, 11:02
Try this: (some text otherwise the message it too short to post)

Creating Translucent Windows

Since Qt 4.5, it has been possible to create windows with translucent regions on window systems that support compositing.

To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground attribute with setAttribute() and ensure that its background is painted with non-opaque colors in the regions you want to be partially transparent.

Platform notes:

* X11: This feature relies on the use of an X server that supports ARGB visuals and a compositing window manager.
* Windows: The widget needs to have the Qt::FramelessWindowHint window flag set for the translucency to work.

girishgowda
2nd July 2010, 02:32
Thank you for the reply.
I have tried this as follows:

setAttribute(Qt::WA_TranslucentBackground, true);
setStyleSheet(KDialogStyle);//where KDialogStyle = "QDialog {color: rgb(32, 37, 240); border: 1px solid #FFFFFF;border-radius: 6px; background-color: rgba(220, 150, 220, 155); }"

But this does not work - the window gets a new color but it is no where near to the color I have set, nor the default color.
Also the default background is seen on the borders of the dialog.
Either I am missing something, or this feature is not yet supported in Qt for Symbian.

My understanding:
To make a window transparent/translucent in Symbian, the window will have to do something like this


Window().SetRequiredDisplayMode(EColor16MA);
Window().SetTransparencyFactor(0);
TRgb backgroundColour = KRgbWhite;
if(KErrNone == Window().SetTransparencyAlphaChannel())
{
backgroundColour.SetAlpha(155);//set a value from 0 to 255
}
Window().SetBackgroundColor(backgroundColour);

I checked the Qt code to find such a thing. But it is not present anywhere.
I am trying to modify the Qt code....

If there are any Qt developers on the forum - who has developed Qt for Symbian, please confirm if this feature is supported.

high_flyer
2nd July 2010, 09:11
But this does not work - the window gets a new color but it is no where near to the color I have set, nor the default color.
I would not say it doesn't work - doesn't work is when nothing happens.
But your code does change things, and even changes colors, just not the ones you thought will come out.
This can have various reasons, from an error on your part, to a visual effect created through translucency, where colors mix because they are translucent.

Hard to say.
Probably the key is in:

Since Qt 4.5, it has been possible to create windows with translucent regions on window systems that support compositing.
The question is if and how this feature is implemented in Symbian.

I have no experience on Symbian, maybe other forum members can help you more with Symbian specifics.