Sorry, still having trouble with this, and getting Read Access error, I'm thinking it's scope related but I don't really understand how I'm supposed to be doing it.

I have a table widget and I'm trying to initialize an item inside it:
Qt Code:
  1. void TableTry::on_btnDoWork_clicked()
  2. {
  3.  
  4. int foundIdx = getOrCreateMeasurementRowIdx(ui.txtMeasurementName->text());
  5.  
  6. // Here is the code executed inside getOrCreateMeasurementRowIdx:
  7. int insertAt = ui.tblMyTable->rowCount();
  8. ui.tblMyTable->insertRow(insertAt);
  9. ui.tblMyTable->setItem(insertAt, 0, new QTableWidgetItem(measurementName)); // Parameter is the lineEdit.text()
  10.  
  11. // Back in on_btnDoWork_clicked():
  12. ui.tblMyTable->item(foundIdx,0)->setText("boooooooo"); // THIS causes error: Access violation reading location 0x00000000
  13. }
To copy to clipboard, switch view to plain text mode 

Is it possible I'm not supposed to be editing items I've already added? Should I always create a new item and then use setItem?

Why can't I access the item I dynamically created?