[Qt-interest] transparent mainwindow and non transparent widget

Pritam Ghanghas pritam_ghanghas at infosys.com
Fri Jul 9 08:49:04 CEST 2010


are you using QMainWindow or simple QWidget for your mainWindow.
Because for me it never failed for QMainWindow, but again I am on Linux.
Never tried it on windows xp. if its making it black, it seems that its
using the QPalette::Base for drawing background. 
try setting autoFillBackground() to false or  setting to Base to a
QColor(0,0,0,0). But setting the base will make your child widgets also
transparent because they will also be using the same colorRole to draw
their background. you will have to explicitly override it for them also.
Or you can do as Ramesh has suggested but in that case you will have to
subclass.

On Fri, 2010-07-09 at 12:09 +0530, Ramesh wrote:
> Override the paint event of the window to which you want to make transparent
> and perform the draw operation (i.e draw the transparent rect by setting the
> opacity)..
> 
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Bart Swinnen
> Sent: Friday, July 09, 2010 11:59 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] transparent mainwindow and non transparent widget
> 
> On 9/07/2010 7:49, Pritam Ghanghas wrote:
> >
> > By default most of the widgets are transparent. I mean their
> > autoFillBackground property is false except for QMainWindows (native
> > widgets I guess). if you want them non transparent you can set it to
> > true with setAutoFillBackground().
> >
> > For making QMainWindow, I have always used
> > setStyleSheet("background: transparent");
> >
> >
> 
> When using setStyleSheet("background: transparent");
> It sets the background of the mainwindow to black on my WinXP.
> Is there something else to set to have it transparent?
> BTW: I'm using 4.7 beta2
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> 
> -----------------------------------------------
> Robosoft Technologies - Come home to Technology
> 
> Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list