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:
void TableTry::on_btnDoWork_clicked()
{
int foundIdx = getOrCreateMeasurementRowIdx(ui.txtMeasurementName->text());
// Here is the code executed inside getOrCreateMeasurementRowIdx:
int insertAt = ui.tblMyTable->rowCount();
ui.tblMyTable->insertRow(insertAt);
ui.
tblMyTable->setItem
(insertAt,
0,
new QTableWidgetItem(measurementName
));
// Parameter is the lineEdit.text()
// Back in on_btnDoWork_clicked():
ui.tblMyTable->item(foundIdx,0)->setText("boooooooo"); // THIS causes error: Access violation reading location 0x00000000
}
void TableTry::on_btnDoWork_clicked()
{
int foundIdx = getOrCreateMeasurementRowIdx(ui.txtMeasurementName->text());
// Here is the code executed inside getOrCreateMeasurementRowIdx:
int insertAt = ui.tblMyTable->rowCount();
ui.tblMyTable->insertRow(insertAt);
ui.tblMyTable->setItem(insertAt, 0, new QTableWidgetItem(measurementName)); // Parameter is the lineEdit.text()
// Back in on_btnDoWork_clicked():
ui.tblMyTable->item(foundIdx,0)->setText("boooooooo"); // THIS causes error: Access violation reading location 0x00000000
}
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?
Bookmarks