title: Qt Designer - window won't get smaller than a QLabel with pixmap
body: <p>I'm creating a program (in Qt Creator 2.8.1, Qt 5.1.1) that basically shows an image, in this case a playing card (along with a few buttons, labels, and a line edit). All widgets are in vertical/horizontal layouts, and the window layout is a grid layout.</p>
  <p>I reimplemented the main window's <em>resize event</em> to get the image to resize correctly and ajust the pixmap to it's size - basically, the label expands vertically as much as it can (vertical size policy set to Expand(1)), and then the image is rescaled.</p>
  <p>When the window is expanded, everything works fine, and both the label and the image resize correctly. However, I can't shrink the window back: that is, when resizing, I can't get the window to have a smaller height than necessary to include the current label size - neither the label nor the image resize. If I shrink the window horizontally, so that, in order to keep the ratio, the image is shrunk (left-most image), then I can shrink the window vertically. Note that, when resizing the window horizontally, only the image/pixmap is shrunk, not the label.</p>
  <p>Here is the code that I'm using to manage the sizes(2):</p>
  <pre><code>void MainWindow::resizeEvent(QResizeEvent* event)
  {
      QMainWindow::resizeEvent(event);
      //Some code that is not causing the problem - I've checked
      showImage();
  }
      
  void MainWindow::showImage()
  { 
      int w = ui-&gt;imageLabel-&gt;width();
      int h = ui-&gt;imageLabel-&gt;height();
  
      //Getting image path from file - also not causing the problem
      QPixmap pixmap(&quot;:/image/path.png&quot;);
  
      //The image is quite big, so I need to
      // set a scaled pixmap to a w x h window, keeping its aspect ratio
      ui-&gt;imageLabel-&gt;setPixmap(pixmap.scaled(w,h,Qt::KeepAspectRatio));
      ui-&gt;imageLabel-&gt;setMask(pixmap.mask());       
  }
  </code></pre>
  <p>And here is the arrangement in Qt Designer and when running:
  <img src="https://i.stack.imgur.com/ef7ew.png" alt="Arrangement" /></p>
  <p>So, to recap:</p>
  <ol>
  <li>When increasing the windows's height, the label and image grow accordingly, keeping its ratio.</li>
  <li>When decreasing the windows's height:
  <ul>
  <li>If the image doesn't have to change, <strong>even if the label does</strong>, the window resizes normally.</li>
  <li>If the image needs to shrink, then the window doesn't resize at all.</li>
  </ul>
  </li>
  <li>When decreasing the windows's width, the window resizes normally
  <ul>
  <li>If necessary to keep the image ratio, the image(pixmap) shrinks, but <em>the label only shrinks horizontally</em></li>
  </ul>
  </li>
  </ol>
  <p>What I find weird is that the pixmap prevents the window from resizing vertically, but has no problem in shrinking if the window is resized horizontally.</p>
  <p>The question is, as it could only be: any ideas on how to solve this?</p>
  <hr />
  <p>(1) Also tried Minimum Expanding, same thing happened. - Also tried resizing the label programatically, but then the other widgets ignore the label's size and don't move, causing overlapping.</p>
  <p>(2) Since I am using Qt for pretty much the first time, I can't/don't know how to copy an amount of code that can be copied, compiled and executed, without filling this question with lots of unimportant code.</p>
  <p><em>Note:</em> Feel free to ask for more information that you think may be useful in finding the problem's cause and/or solution.</p>