title: Pyqt: Enforcing sizeHint() dimensions on two-widget app with layout manager
body: <p>I have two widgets residing one next to each other, <code>WidgetA</code> and <code>WidgetB</code>, on a <code>QDialog</code>, with a horizontal Layout Manager.<br>
  I am trying to enforce the following size/resize policies:<br>
  For <strong><code>WidgetA</code></strong>:  </p>
  
  <ul>
  <li>Horizontally: Width should be 900 with the ability to shrink (up to 100), and to expand (to whatever). </li>
  <li>Vertically: Height should be 600 with the ability to expand (to whatever).</li>
  </ul>
  
  <p>For <strong><code>WidgetB</code></strong>:</p>
  
  <ul>
  <li>Horizontally: Width should be Fixed to 600.</li>
  <li>Vertically: Height should be 600, with the ability to expand (to whatever) - same as <code>WidgetA</code>.</li>
  </ul>
  
  <p>But no matter which size policy I choose for WidgetA, it still won't take up width of 900.<br>
  Here's a code sample:</p>
  
  <pre><code>class WidgetA(QTextEdit):
  
      def __init__(self, parent = None):
          super(WidgetA, self).__init__(parent)
          #self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding)   --&gt; WidgetA width still smaller than 900
          #self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.MinimumExpanding)     --&gt; WidgetA will be set to minimumSizeHint()
          #self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)       --&gt; not good for me, since I want WidgetA to be able to shrink up to minimumSizeHint().width()
          #self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)     --&gt; not good for me for the same reason - I want WidgetA to be able to shrink up to minimumSizeHint().width()
  
      def minimumSizeHint(self):
          return QSize(100, 600)
  
      def sizeHint(self):
          return QSize(900, 600) 
  
  
  class WidgetB(QTextEdit):
  
      def __init__(self, parent = None):
          super(WidgetB, self).__init__(parent)
          self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
  
      def sizeHint(self):
          return QSize(600, 600)
  
  class MainForm(QDialog):
  
      def __init__(self, parent = None):
          super(MainForm, self).__init__(parent)
  
          label_a = QLabel('A')
          widget_a = WidgetA()
          label_a.setBuddy(widget_a)
  
          label_b = QLabel('B')
          widget_b = WidgetB()
          label_b.setBuddy(widget_b)
  
          hbox = QHBoxLayout()
  
          vbox = QVBoxLayout()
          vbox.addWidget(label_a)
          vbox.addWidget(widget_a)
          widget = QWidget()
          widget.setLayout(vbox)
  
          hbox.addWidget(widget)
  
          vbox = QVBoxLayout()
          vbox.addWidget(label_b)
          vbox.addWidget(widget_b)
          widget = QWidget()
          widget.setLayout(vbox)
  
          hbox.addWidget(widget)
  
          self.setLayout(hbox)
  
  
  
  def run_app():
      app = QApplication(sys.argv)
      form = MainForm()
      form.show()
      app.exec_()
  
  if __name__ == '__main__':
      run_app()
  </code></pre>
  
  <p>The closest I could get is when I set:  </p>
  
  <pre><code>self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding)
  </code></pre>
  
  <p>On <code>WidgetA</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/MjGcv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MjGcv.png" alt="enter image description here"></a></p>
  
  <p>It seems like <code>WidgetB</code> is taking a bite off of <code>WidgetA</code>'s 900 width (eliminating <code>WidgetB</code> does the trick), but I shouldn't be limited by the window's width.<br>
  What's preventing from the <strong>window itself</strong> (the <code>MainForm</code>) to automatically expand horizontally in order to account for both <code>WidgetA</code>'s 900 width and <code>WidgetB</code>'s fixed 600 width?</p>