title: QT layout widget resizing
body: <p>Im having a problem with my Layouts in QT. Im trying to achieve a List of widgets which can be expanded and contracted in the following manner:</p>
  
  <pre><code>|------------|                                            |------------|
  |Title 1     |                                            |Title 1     | Widget1
  |------------|                                            |------------|
  |QTextEdit1  |   Widget 1                                 |Title 2     |
  |            |                                            |------------|                                                  
  |------------|Which, by clicking on the title, contract:  |QTextEdit2  | Widget2
  |------------|                                            |            |
  |Title 2     |                                            |------------|
  |------------|                                                       
  |QTextEdit1  |
  |            |   Widget 2
  |------------|
  </code></pre>
  
  <p>Problem is, so far ive only be able to achieve the following: (After clicking on title 1)</p>
  
  <pre><code>|------------|                                                      
  |Title 1     |                                                     
  |------------|                                                       
  |            |                                                      
  |            |                                                                                                   
  |------------|     
  |------------|                                                       
  |Title 2     |                                                 
  |------------|                                                       
  |QTextEdit1  |
  |            |
  |------------|
  </code></pre>
  
  <p>That is, i am able to make the QtextEdit of my first widget disappear, keeping the title height intact (this is important), but the second widget does not replace the space left by the first QTextEdit. It is as if the QtextEdit is still there, and the second widget cannot occupy that space.
  ¿Does anyone know how to solve this? I have the feeling its not that complicated but Ive looked around and I havent been able to solve it. I have tried setting a maxmimum height for the widget1 when I contract it, but that doesnt seem to work. Oh, and each widget contains a QVBoxLayout, where title and QtextEdit are inserted, and then the list of widgets is another QVBoxLayout, where all the widgets are inserted.</p>
  
  <p><strong>EDITED:</strong> Added some source code by request</p>
  
  <p>Constructor:</p>
  
  <pre><code>mainLayout = new QVBoxLayout;
  QHBoxLayout *headerLayout = new QHBoxLayout;
  title = new QLabel("My title!!");
  
  m_arrowLabel-&gt;setPixmap(m_arrowDown);
  m_activated = true;
  title-&gt;setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
  title-&gt;setMaximumHeight(16);
  headerLayout-&gt;addWidget(title, 0, Qt::AlignLeft);
  headerLayout-&gt;setContentsMargins(0,0,0,0);
  
  textEdit = new QTextEdit;
  textEdit-&gt;setReadOnly(true);
  textEdit-&gt;setText("My text!!!");
  textEdit-&gt;setMaximumHeight(textEdit-&gt;document()-&gt;size().height() + 50);
  
  mainLayout-&gt;addLayout(headerLayout);
  mainLayout-&gt;addWidget(textEdit);
  mainLayout-&gt;setContentsMargins(QMargins(0,0,0,0));
  this-&gt;setLayout(mainLayout);
  </code></pre>
  
  <p>Mouse Press event:</p>
  
  <pre><code>event-&gt;accept();
  if (event-&gt;buttons() &amp; Qt::LeftButton)
  {
      if (m_activated)
      {
          m_activated = false;
          textEdit-&gt;setVisible(false);
  
      }else
      {
          m_activated = true;
          textEdit-&gt;setVisible(true);
      }
  }
  </code></pre>
  
  <p>On my window where I populate it with widgets:</p>
  
  <pre><code>    m_mainLayout = QVector&lt;QVBoxLayout *&gt; (10);
  
      for (int i=0; i&lt;m_mainLayout.size(); i++)
      {
          myWidget[i] = new myWidget;
          myWidget[i]-&gt;setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
          m_mainLayout-&gt;addWidget(myWidget[i]);
  
      }
  </code></pre>