title: QWidget resizing problems
body: <p>I'm fighting for hours with following problem.</p>
  
  <p>Widget <code>A</code> is container with <code>QHBoxLayout</code> for <code>QLabel</code> objects. I want to put such widget in other widget, with constant height equal to <code>A</code>'s height, and minimum width equal to <code>A</code>'s width (but width can be changed).</p>
  
  <p>In <code>A</code> constructor I have following code:</p>
  
  <pre><code>QHBoxLayout* mLayout = new QHBoxLayout();
  for (auto e : wordsList)
      mLayout-&gt;addWidget(e);
  mLayout-&gt;setSpacing(0);
  mLayout-&gt;setMargin(0);
  mLayout-&gt;setSizeConstraint(QLayout::SetFixedSize);
  setLayout(mLayout);
  </code></pre>
  
  <p>And there is the body of <code>B</code>:</p>
  
  <pre><code>class B : public QWidget
  {
      Q_OBJECT
  public:
      explicit B(A *a0, QWidget *parent = 0)
          : QWidget(parent),
            a(a0)
      {
          a-&gt;setParent(this);
          setSizePolicy(QSizePolicy());
          setFixedSize(sizeHint());
      }
      QSize minimumSize() const
      {
          return a-&gt;size();
      }
      QSize sizeHint() const
      {
          return minimumSize();
      }
  private:
      A *a;
  };
  </code></pre>
  
  <p>In <code>main()</code> I call show() on <code>B</code>'s instance. In effect, I get big, fully resizeable window, bigger than <code>A</code>. <code>A</code> is frozen, doesn't resize with <code>B</code>.</p>
  
  <p>I want <code>B</code> to start with the same size as <code>A</code> and to be resizeable only horizontally (but with minimum width equal to <code>A</code>).</p>
  
  <p>How can I achieve this?</p>
  
  <p>And why <code>setSizePolicy()</code> and <code>setFixedSize()</code>, <code>minimumSize()</code> and even <code>sizeHint()</code> don't work? </p>
  
  <p>Can this be because I use <code>B</code> as a main window?</p>
  
  <p>If I use layout in <code>B</code>, this probably should be another <code>QHBoxLayout</code>. But when he has too much space, he fits his component, so I would need to use <code>QSpacerItem</code> and resize him always, when <code>B</code> is resizing. But I don't know order, in which widgets are receiving <code>QResizeEvent</code>: if <code>B</code> gets it before my spacer, I will do nothing. I probably could use <code>eventFilter</code>, but still, this is too complicated (behaviour I need is pretty simple!).</p>