I have my QTableWidge
here called ui->availableMeasurementsTableWidget
and I want to set the row names and column names.
My goal is to use the variable columnName
to change each row of the ui->availableMeasurementsTableWidget
but every time I insert a new item inside ui->availableMeasurementsTableWidget
it crash.
Why does this happen?
/* Find total rows */
int totalRows = MeasurementTable::staticMetaObject.propertyCount() - MeasurementTable::staticMetaObject.propertyOffset();
ui->availableMeasurementsTableWidget->setRowCount(totalRows);
ui->availableMeasurementsTableWidget->setColumnCount(1);
for(int i = 0; i < totalRows; i++){
int typeID = MeasurementTable::staticMetaObject.property(i).typeId();
QString columnName = MeasurementTable::staticMetaObject.property(i).name();
QTableWidgetItem *qTableWidgetItem = new QTableWidgetItem();
/* Set it to a checked state */
qTableWidgetItem->setCheckState(Qt::CheckState::Unchecked);
/* How can I change the row name for the availableMeasurementsTableWidget ? */
/* Insert -> Here it crash */
ui->availableMeasurementsTableWidget->setItem(i,0, qTableWidgetItem);
}