title: Qt - setLayout() and setCentralWidget()
body: <p>I recently started to work with Qt and Qwt. I can't find my mistake by myself. Please help me. There is the code.
  I know that my mistakes in somewhere here:</p>
  
  <p>.h file</p>
  
  <pre><code>  ...
  
    class MainWindow : public
    QMainWindow
    {
        Q_OBJECT
        QWidget *centralWidget;
    public:
        MainWindow(QWidget *parent = 0);
    ...
    }
  </code></pre>
  
  <p>.cpp</p>
  
  <pre><code>  MainWindow::MainWindow(QWidget *parent):
    QMainWindow(parent) {
    ...
    ...
    void MainWindow::setPlotButton() {
        button = new QPushButton("push"),
        button-&gt;setCheckable(true);   
        connect(button, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)))
        QHBoxLayout *plotsLayout = new QHBoxLayout;
        plotsLayout-&gt;setSpacing(10);
        plotsLayout-&gt;addWidget(funPlot);
        QHBoxLayout *buttonsLayout = new QHBoxLayout ;
        buttonsLayout-&gt;addWidget(button);
        QVBoxLayout *widgetLayout = new QVBoxLayout;
        widgetLayout-&gt;addLayout(plotsLayout);
        widgetLayout-&gt;addLayout(buttonsLayout);
        setLayout(widgetLayout);
    ...
    }
  </code></pre>
  
  <p>I recieve a message "QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout". I found that I have to use a function setCentralWidget(), but what exactly I should change? </p>