title: Removing widgets from QGridLayout
body: <p>I try to remove widgets from a specified row in a <code>QGridLayout</code> like this:</p>
  
  <pre><code>void delete_grid_row(QGridLayout *layout, int row)
  {
      if (!layout || row &lt; 0) return;
  
      for (int i = 0; i &lt; layout-&gt;columnCount(); ++i) {
          QLayoutItem* item = layout-&gt;itemAtPosition(row, i);
          if (!item) continue;
  
          if (item-&gt;widget()) {
              layout-&gt;removeWidget(item-&gt;widget());
          } else {
              layout-&gt;removeItem(item);
          }
          delete item;
      }
  }
  </code></pre>
  
  <p>But when I call it, the app crashes with SIGSEGV on <code>delete item</code> in the first iteration. Any ideas?</p>