Qt Code:
  1. #include <QtGui>
  2.  
  3. int main(int argc, char **argv){
  4. QApplication app(argc, argv);
  5. QWidget *w = new QWidget;
  6. mw.setCentralWidget(w);
  7. w->setAutoFillBackground(true);
  8. w->setStyleSheet("background-color: red;");
  9. mw.show();
  10. return app.exec();
  11. }
To copy to clipboard, switch view to plain text mode 
or...
Qt Code:
  1. #include <QtGui>
  2.  
  3. int main(int argc, char **argv){
  4. QApplication app(argc, argv);
  5. QWidget *w = new QWidget;
  6. mw.setCentralWidget(w);
  7. w->setAutoFillBackground(true);
  8. // w->setStyleSheet("background-color: red;");
  9. QPalette p = w->palette();
  10. p.setColor(QPalette::Background, Qt::yellow);
  11. w->setPalette(p);
  12. mw.show();
  13. return app.exec();
  14. }
To copy to clipboard, switch view to plain text mode