title: Set background of QMainWindow central widget
body: <p>Using Qt 4.8.4 on Windows 7 (MSVC 2010) I have a standard <code>QMainWindow</code> in my app with a toolbar. I want the toolbar to stay grey, but the central widget should have a white background. Calling <code>centralWidget-&gt;setStyleSheet("background-color: white;")</code> at first seemed to do the job, but using it with a Designer-generated widget (a <code>Q_OBJECT</code>) doesn't. Subsequently I toyed around with various other methods to set a style sheet (also using Designer) to no avail.</p>
  
  <p>To see this effect, add or remove the <code>Q_OBJECT</code> line in <code>test.h</code>. When it's there, only the label gets a white bg. If <code>Q_OBJECT</code> is commented out, the whole central widget is white. Of course, I want the whole area white, but also need <code>Q_OBJECT</code>.</p>
  
  <p>Here's the files:</p>
  
  <p><strong>main.cpp:</strong></p>
  
  <pre><code>#include "test.h"
  
  class testwin : public QMainWindow {
  public:
      QWidget     *centralWidget;
      QToolBar    *mainToolBar;
  
      testwin(QWidget *parent = 0) : QMainWindow(parent) {
          centralWidget = new test(this);
          setCentralWidget(centralWidget);
          mainToolBar = new QToolBar(this);
          this-&gt;addToolBar(Qt::TopToolBarArea, mainToolBar);
      };
  
      ~testwin() {};
  };
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      testwin w;
      w.centralWidget-&gt;setStyleSheet("background-color: white;");
      w.show();
      return a.exec();
  }
  </code></pre>
  
  <p><strong>test.h:</strong></p>
  
  <pre><code>#include &lt;QtGui&gt;
  
  class test : public QWidget
  {
      Q_OBJECT    // remove this
  
  public:
      QLabel *label;
  
      test(QWidget *parent = 0) {
          resize(400, 300);
          label = new QLabel(this);
          label-&gt;setText("Test");
      };
  };
  </code></pre>
  
  <p>Status update:</p>
  
  <ul>
  <li><code>setStyleSheet("QWidget { background-color: white; }")</code> does NOT solve the issue</li>
  <li>I succeed in making every Widget (including popup dialogs) white, but that's not what I want.</li>
  </ul>