title: C++ Qt Table Rows Clearing When New Row Added
body: <p>I am using the following code to create an object and then add a row to a qt table and populate it.
  However after adding the first new row, the next time the button is clicked and a new row is added all but the first column of the row above are cleared.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks,</p>
  
  <p>First Click Adds Row Just Fine
  <img src="https://i.stack.imgur.com/jp1St.png" alt="First Click Adds Row Just Fine"></p>
  
  <p>Second Click Clears Most Of The Row Above
  <img src="https://i.stack.imgur.com/R4rYr.png" alt="Second Click Clears Most Of The Row Above"></p>
  
  <pre><code>void MainWindow::on_btnAdd_clicked()
  {
  Inventory i;
  int it = ui-&gt;cboItem-&gt;itemData(ui-&gt;cboItem-&gt;currentIndex()).toInt();
  double q = ui-&gt;spinQnty-&gt;value();
  int l = ui-&gt;cboLoc-&gt;itemData(ui-&gt;cboLoc-&gt;currentIndex()).toInt();
  
  Item item(it);
  Location loc(l);
  
  i.insert(it,q,l);
  i.setItem(item);
  i.setQnty(q);
  i.setLoc(loc);
  
  QTableWidgetItem *newItem1 = new QTableWidgetItem(QString::fromStdString(i.getItem().getItem_Name()));
  QTableWidgetItem *newItem2 = new QTableWidgetItem(QString::fromStdString(i.getItem().getCategory().getCatName()));
  QTableWidgetItem *newItem3 = new QTableWidgetItem(QString::fromStdString(cn.dbl_to_str(i.getQnty())));
  QTableWidgetItem *newItem4 = new QTableWidgetItem(QString::fromStdString(i.getLoc().getLocName()));
  QTableWidgetItem *newItem5 = new QTableWidgetItem();
  newItem5-&gt;setData(Qt::UserRole,QVariant(i.getInv_ID()));
  
  QIcon qi;
  qi.addFile(QString::fromStdString("red_error_warning_icon.svg"));
  newItem5-&gt;setIcon(qi);
  
  int j = ui-&gt;mainTable-&gt;rowCount();
  
  ui-&gt;mainTable-&gt;insertRow(j);
  ui-&gt;mainTable-&gt;setItem(j,0,newItem1);
  ui-&gt;mainTable-&gt;setItem(j,1,newItem2);
  ui-&gt;mainTable-&gt;setItem(j,2,newItem3);
  ui-&gt;mainTable-&gt;setItem(j,3,newItem4);
  ui-&gt;mainTable-&gt;setItem(j,4,newItem5);
  }
  </code></pre>