PDA

View Full Version : Transparent background Style



Lele
17th July 2006, 10:24
Hi,
I'm trying to build a new QStyle where my Background will be transparent.

I tried this in my overridden polish(QPalette &palette)
palette.setBrush(QPalette::Window, Qt::transparent);

But I get a black background,
is there a different way to achieve transparency?

Thanks
Bye

jpn
17th July 2006, 10:35
Use QWidget::setWindowOpacity (http://doc.trolltech.com/4.1/qwidget.html#windowOpacity-prop)() for top level widgets (requires a composite manager on X11). Child widgets are transparent by default in Qt 4.1.

Lele
17th July 2006, 10:54
Hi, thanks for answering
well, after some more research I found this http://lists.trolltech.com/qt-interest/2006-01/thread01463-0.html

which is exactly my problem, actually I'd like only some parts of my style will be transparent, not the entire window, and as stated in http://doc.trolltech.com/qq/qq16-background.html

"Qt 3.3 introduced a new widget property called windowOpacity for making top-level widgets (windows) transparent. This property can't be used to make child widgets semi-transparent, and it only works on window systems that support this feature (Mac OS X and Windows 2000 or later). In addition, the windowOpacity property applies to the widget as a whole, not to individual shapes or pixels."

So if I want a mainwindow(top level widget) with just the background transparent there's no way to achieve it?

thanks again

jpn
17th July 2006, 11:50
I'm not 100% sure but yes, I believe there is no way to make only parts of a top level window transparent. Qt doesn't draw the top level window, it comes from the underlying system. Qt can only provide some hints to the platform what kind of window should it be (like transparent).

jacek
17th July 2006, 11:55
I'd like only some parts of my style will be transparent, not the entire window
How about QWidget::setMask()?

Lele
17th July 2006, 12:02
thanks,
well in my case I'd need all Background as tansparent, so not really a region but all the area
where the other widgets are attached.