我有 4 个具有 4 行和 4 列的 QtableView。但是,单元格中充满了垃圾值,并且每当编辑单元格中的值时,应用程序就会终止。示例代码,
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;
}
请帮忙