I tried the following code but in vain.

Qt Code:
  1. setAutoFillBackground(true);
  2. //QPalette palette = this->palette();
  3. QPalette palette;
  4. palette.setBrush(QPalette::Window, QBrush(QPixmap(":/Resources/topGradient.png")));
  5. this->setPalette(palette);
To copy to clipboard, switch view to plain text mode 


I tried with stylesheet but doing so caused the child widgets (buttons, labels) inherit the background image. So it's not suitable for my need.

Qt Code:
  1. setStyleSheet("background-image: url(:/Resources/topGradient.png);");
To copy to clipboard, switch view to plain text mode 

Can you please tell me why the use of QPalette for setting background image did not work?

Thanks.