0

I would like to independently change the background image of each page of the stacked widget . However, when I add background-image: to the styleSheet tab on Qt creator, the result is that all the pages of the stacked widget get that background image. Is there a way to set a different background image to each page with out using QT's styleSheet Method

1 Answers1

1

Try this:

QWidget *widget = stackWidget->currentWidget();
QPixmap background("/home/user/Pictures/background.png");
bkgnd = background.scaled(widget->size(), Qt::IgnoreAspectRatio);
QPalette palette;
palette.setBrush(QPalette::Background, background);
widget->setPalette(palette);
snoopy
  • 328
  • 1
  • 12