I have a mainwindow with a Qwidget as the central widget, which in turn consists of serveral widgets. Both the mainwindow and the central widget have a a background image but I’m not able to superimpose the central widget background on the mainwindow background. The central widget background image is translucent so I should be able to see the foggy background image of the mainwindow. The code I’m using now in the mainwindow is
QPalette p = palette();
QPixmap pixmap1("background.jpg");
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect rect = desktopWidget->availableGeometry();
QSize size(rect.width() , rect.height());
QPixmap pixmap(pixmap1.scaled(size));
p.setBrush(QPalette::Background, pixmap);
setPalette(p);
CentralWidget *cw = new CentralWidget();
cw->setStyleSheet("background-image: url(bckng.png);");
Even if I try to set only the central widget background, the image appears as a background for the widgets inside the central widget and not the central widget as a whole.
I know I have not framed the question very well, but if you are able to understand it, please do help me.
Thanks.
↧