[Qt-interest] How to add a background image for MainWindow

Karol Krizka kkrizka at gmail.com
Thu Jun 18 10:12:56 CEST 2009


On Thu, 2009-06-18 at 09:25 +0800, Kermit Mei wrote:
> Hello, community!
> 
> I implemented a MainWindow which inherited from QWidget. Now, I need to
> add an background for it. I use 
> setStyleSheet("background-image: url(:/images/background.jpg)");
> in MainWindow::MainWindow(...), but all the widgets include all the
> buttons on it has a background from background.jpg, it looks very
> confused. 
> 
The stylesheet applies to all subchildren. So to correct it, try this as
the stylesheet:
MainWindow
{
	background-image: url(:/images/background.jpg)
}

This way only the widgets that are of MainWindow get the background.

--
Cheers,
Karol Krizka
http://www.krizka.net

> How can I correct it?
> 
> Thanks:)
> 
> 
> 
> _______________________________________________
> 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