title: How to properly use adjustSize() in Qt
body: <p>I'm new to Qt, and this issue about auto resizing has driven me crazy.</p>
  
  <p>I create a class called <code>RenderArea</code> that inherits <code>QWidget</code>. In its <code>paintEvent()</code>, I use a <code>QPainter</code> to draw an image. In order for the whole window to scale with the image, I resize before painting. The relevant code is</p>
  
  <pre><code>if (image &amp;&amp; !image-&gt;isNull())
  {
      resize(image-&gt;size());
      painter.drawImage(image-&gt;rect(), *image, image-&gt;rect());
  }
  </code></pre>
  
  <p>However, <code>RenderArea</code> will stretch too much through other widgets (like buttons and menus). It is contained in a <code>centralWidget</code> with a vertical layout. But when I call <code>centralWidget-&gt;adjustSize()</code> it does not scale everything together, but instead shrinks <code>RenderArea</code> t and hides the image. </p>
  
  <p>How do I instruct the central widget as well as the window to scale with the new size of my customized widget? I know I could use a <code>QLabel</code> and set its <code>scaledContents</code> to be true, but I need a lot of other sophisticated rendering so a simple <code>QLabel</code> is not enough.</p>