PDA

View Full Version : QWidget background



salmanmanekia
21st July 2008, 14:39
Hi,
I have adopted two widget in my scene,basically i have a view(qgraphicsview) -> scene(qgraphicsscene) and in the scene i have two qwidget derived class drawing some paint and buttons ,the problem i am facing is that that i have set the background of my view from a jpeg file ,and i want the whole background of window to be from that jpeg file ,but due to two widgets i am also seeing some gray area as surronded by the widget..
hope i am clear :)

caduel
21st July 2008, 15:23
did you (not) set QWidget::autoFillBackground()?

salmanmanekia
23rd July 2008, 10:23
i am setting the autoFillBackground() and then setting palette by setPalette(const QPalette) ,this is how i am trying to do this but it throws an error .


QPalette *palette;
setAutoFillBackground(TRUE);
palette->setBrush(QPalette::Window,QPixmap(BACKGROUND_DIR_L OCATION));

setPalette(palette);---->it throws error here

salmanmanekia
23rd July 2008, 10:33
i have solved it,not a big thing...jus not declare palette as pointer..:)


QPalette palette;
palette.setBrush(this->backgroundRole(), QBrush(QImage("backgroundImage.jpg")));

this->setPalette(palette);

aamer4yu
23rd July 2008, 11:55
Of course....

QPalette *palette;
setAutoFillBackground(TRUE);
palette->setBrush(QPalette::Window,QPixmap(BACKGROUND_DIR_ LOCATION));

setPalette(palette);---->it throws error here


You didnt create an instance of palette like -
palette = new QPalette();