title: Delete A Row From QGridLayout
body: <p>All, I am maintaining a <code>QGridLayout</code> of <code>QLabels</code> which show the coefficients of a polynomial.  I represent my polynomial using <code>QList&lt;double&gt;</code>.</p>
  
  <p>Each time I update my coefficients, I update my labels.  When changing the size of the list, my method <strong>does not</strong> works well.  <code>QGridLayout::rowCount()</code> doesn't update correctly.  I am wondering if there's a way to remove rows from a QGridLayout.</p>
  
  <hr>
  
  <p>Code follows, updating the <code>QGridLayout</code> size with more (or less) <code>QLabels</code></p>
  
  <pre><code>int count = coefficients-&gt;count(); //coefficients is a QList&lt;double&gt; *
  if(count != (m_informational-&gt;rowCount() - 1)) //m_information is a QGridLayout
  {
      SetFitMethod(0);
      for(int i = 0; i &lt; count; ++i)
      {
          QLabel * new_coeff = new QLabel(this);
          new_coeff-&gt;setAlignment(Qt::AlignRight);
          m_informational-&gt;addWidget(new_coeff, i+1, 0);
          QLabel * param = new QLabel(this);
          param-&gt;setAlignment(Qt::AlignLeft);
          param-&gt;setText(QString("&lt;b&gt;&lt;i&gt;x&lt;/i&gt;&lt;sup&gt;%2&lt;/sup&gt;&lt;/b&gt;").arg(count-i-1));
          m_informational-&gt;addWidget(param, i+1, 1);
          QSpacerItem * space = new QSpacerItem(0,0,QSizePolicy::Expanding);
          m_informational-&gt;addItem(space, i+1, 1);
      }
  
      m_informational-&gt;setColumnStretch(0, 3);
      m_informational-&gt;setColumnStretch(1, 1);
      m_informational-&gt;setColumnStretch(2, 1);
  }
  </code></pre>
  
  <p>The SetFitMethod (it's an initial mockup)</p>
  
  <pre><code>void SetFitMethod(int method)
  {
      ClearInformational();
      switch(method)
      {
      case 0: //Polynomial fit
          QLabel * title = new QLabel(this);
          title-&gt;setText("&lt;b&gt; &lt;u&gt; Coefficients &lt;/u&gt; &lt;/b&gt;");
          title-&gt;setAlignment(Qt::AlignHCenter);
          m_informational-&gt;addWidget(title,0,0,1,3, Qt::AlignHCenter);
      }
  }
  </code></pre>
  
  <p>The Clearing Method:</p>
  
  <pre><code>void ClearInformational()
  {
      while(m_informational-&gt;count())
      {
          QLayoutItem * cur_item = m_informational-&gt;takeAt(0);
          if(cur_item-&gt;widget())
              delete cur_item-&gt;widget();
          delete cur_item;
      }
  }
  </code></pre>