我有4个QtableViews,包含4行和4列。但是,单元格中填充了垃圾值,只要编辑单元格中的值,应用程序就会终止。 示例代码,
QTableView* const calibrationViews[H20_Num_Ranges]=
{calibration_ui->CalibrationView1,
calibration_ui->CalibrationView2,
calibration_ui->CalibrationView3,
calibration_ui->CalibrationView4
};
calibrationViews[i]->resizeColumnToContents(0);
calibrationViews[i]->resizeColumnToContents(1);
calibrationViews[i]->horizontalHeader()->setStretchLastSection(true);
connect(_calibrationModels[i],
SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(ProcessGUICalibrationChange()));
QModelIndex gainIndex = _calibrationModels[0]->index(0,
H20CalibrationModel::GainColumn);
newVal = gainIndex.data(Qt::DisplayRole).toString().toFloat(&ok);
if (!qFuzzyCompare(calibration.probe[0].temperatureAdcGain,
newVal))
{
calibration.probe[0].temperatureAdcGain= newVal;
calibrationChanged = true;
}
// Offset
QModelIndex offsetIndex = _calibrationModels[0]->index(0,
H20CalibrationModel::OffsetColumn);
newVal = offsetIndex.data(Qt::DisplayRole).toString().toFloat(&ok);
if (!qFuzzyCompare(calibration.probe[0].temperaturAdcOffset,
newVal))
{
calibration.probe[0].temperaturAdcOffset = newVal;
calibrationChanged = true;
}
请帮助