title: Keeping the aspect ratio of a sub-classed QWidget during resize
body: <p>I'm creating a new widget, by subclassing the QWidget class. I'd like to be able to set a ratio (for its height and its width) for this widget, which will always be maintained.</p>
  
  <p>For this, I've always searched, using the Qt5 documentation, Google, and Stackoverflow. Obviously, I've found answers: in particular, <a href="https://stackoverflow.com/questions/452333/how-to-maintain-widgets-aspect-ratio-in-qt?s=1|1.6690">this one</a>. But, unfortunately, not even one is fully effective:</p>
  
  <ul>
  <li>Setting the <code>sizeIncrement</code> does totally nothing, even if the widget is a window</li>
  <li>I tried to overload resizeEvent, but I really don't know how to do this...</li>
  <li><p>If I follow <a href="https://stackoverflow.com/a/1160476/3738866">this answer</a>, two things:</p>
  
  <ol>
  <li>If the widget is a top-level window, the ratio isn't maintained at all, I can resize it as I want.</li>
  <li>If I place this widget in a layout, if I just increase both width and height of the window, the ratio is maintained. But as soon as I increase the width or the height to much, the widget is flattened. Instead, I would like that the layout automatically adjust its size to keep the widget's ratio.</li>
  </ol></li>
  </ul>
  
  <p>So, how could I manage to keep the aspect ratio of a subclassed QWidget?</p>