void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const { CylindersModel *mymodel = qobject_cast<CylindersModel *>(currCombo.model); TankInfoModel *tanks = TankInfoModel::instance(); QModelIndexList matches = tanks->match(tanks->index(0,0), Qt::DisplayRole, currCombo.activeText); int row; if (matches.isEmpty()) { // we need to add this tanks->insertRows(tanks->rowCount(), 1); tanks->setData(tanks->index(tanks->rowCount() -1, 0), currCombo.activeText); row = tanks->rowCount() - 1; } else { row = matches.first().row(); } int tankSize = tanks->data(tanks->index(row, TankInfoModel::ML)).toInt(); int tankPressure = tanks->data(tanks->index(row, TankInfoModel::BAR)).toInt(); // don't f**k the other data, jimmy. if ( mymodel->data(thisindex, CylindersModel::TYPE).toString() == currCombo.activeText){ return; } mymodel->setData(IDX(CylindersModel::TYPE), currCombo.activeText, Qt::EditRole); mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), tankPressure); mymodel->passInData(IDX(CylindersModel::SIZE), tankSize); }