title: Qt: how to make mainWindow automatically resize when centralwidget is resized?
body: <p>I would like to have my CentralWidget a certain size. What do I need to do to make my mainWindow resize along it's central widget? here the code that doesn't work:</p>
  
  <pre><code>int main (int argc, char **argv) {
      QApplication app(argc, argv);
  
      QGLFormat glFormat;
      glFormat.setVersion(4,2);
      glFormat.setProfile( QGLFormat::CompatibilityProfile);
  
      QGLWidget* render_qglwidget = new MyWidget(glFormat);
  
      QGLContext* glContext = (QGLContext *) render_qglwidget-&gt;context();
      glContext-&gt;makeCurrent();
  
  
      QMainWindow* mainWindow = new MyMainWindow();
      render_qglwidget-&gt;resize(720, 486);
      mainWindow-&gt;setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
      mainWindow-&gt;setCentralWidget(render_qglwidget);
  
      render_qglwidget-&gt;resize(720, 486);
  
      mainWindow-&gt;show();
  
      return app.exec();
  }
  </code></pre>
  
  <p>the window that opens will be very small.</p>
  
  <p>i can set the size of the mainwindow using</p>
  
  <pre><code> mainWindow-&gt;resize(720, 486);
  </code></pre>
  
  <p>and the centralwidget will also change it's size. but the central widget will be slightly squashed because the toolbar of the mainWindow also lies within those 486 pixels.</p>
  
  <p>How to let the mainWindow resize automatically?</p>