title: QGridLayout 3x3 grid resize widgets
body: <p>I have 9 QWidgets. Sometimes they are invisible. They are all in a 3x3 grid.</p>
  
  <pre><code>[0][3][6]
  [1][4][7]
  [2][5][8]
  </code></pre>
  
  <p>Now if for example widget 3 is made invisible, other widgets should should resize:</p>
  
  <pre><code>[   0   ][   6   ]
  [  1 ][  4 ][  7 ]
  [  2 ][  5 ][  8 ]
  </code></pre>
  
  <p>The same should happen vertically, basically all the empty space should be filled but I'm not sure how to do that. When I set a widget invisible, the empty space is not taken.</p>
  
  <pre><code>QGroupBox *parent = getParent();
  QGridLayout *layout = new QGridLayout;
  layout-&gt;setMargin(0);
  layout-&gt;setMargin(5);
  int w = parent-&gt;geometry().width();
  int h = parent-&gt;geometry().height();
  QSize min(w/3-2*layout-&gt;spacing(),h/3-2*layout-&gt;spacing());
  QSize max(w,h);
  for (int n = 0; n &lt; 6; ++n)
  {
      layout-&gt;setRowStretch(n,6);
      layout-&gt;setColumnStretch(n,6);
  }
  
  for (size_t n = 0, t = widgets.size(); n &lt; t; ++n)
  {
      QWidget *widget = widgets[n];
      widget-&gt;setMinimumSize(min);
      widget-&gt;setMaximumSize(max);
      widget-&gt;setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
      layout-&gt;addWidget(widget);
  }
  </code></pre>
  
  <p>Thanks in advance for the help.</p>