PDA

View Full Version : Alpha background color though stylesheets on standalone dialogs / widgets



bharat
18th September 2009, 10:15
Hi,

I seem to have a weird problem. I am hoping for some pointers.

Goal
-----

1. A Tray Icon
2. No Main Window
3. Launch standalone widgets / dialogs based on action chosen from the tray icon menu.

Issue that I am facing
--------------------------

I would like to have a background with an alpha component. For my widgets / dialogs.
If I set my style-sheet to "background-color:rgb(0,0,0)", things are fine. However, If I try "background-color:rgba(0,0,0,200)" or something like that, I just get a completely transparent widget / dialog.

This style-sheet (along with alpha) works on QMainWindow which comes with a default UI application in the QtCreator.

I tried the style-sheet both from the Form Designer and by setting the style-sheet in code. It doesn't seem to make any difference.

Any pointers on what I might be doing wrong ? I know I can override the paintEvent method and get whatever I want, but it would be far more complicated and time consuming.

Thank you.

Note: I am using Qt 4.5.2 on Snow Leopard (I tried some of these experiments on Windows and it didn't help)

Bharat Varma

yogeshgokul
18th September 2009, 10:32
I suggest you to go through shaped clock example (http://doc.trolltech.com/4.5/widgets-shapedclock.html). This is quite similar with your goals. And you can use QWidget::setWindowOpacity() (http://doc.trolltech.com/4.5/qwidget.html#windowOpacity-prop) too.