void Limitcard_Form::deleteLDet(){ QModelIndex index = tableView->currentIndex(); if (!index.isValid()) return; QSqlDatabase db = QSqlDatabase::database(); db.transaction(); QSqlRecord record = model->record(index.row()); int r = QMessageBox::question(this, tr("Удаление материала"), tr("Удалить \"%1\"?") .arg(record.value(Limit_Title).toString()), QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape); if (r == QMessageBox::No) { db.rollback(); return; } QSqlQuery query; query.exec(QString("DELETE FROM limitcard WHERE id = %1") .arg(record.value(Limit_Id).toInt())); db.commit(); model->removeRow(tableView->currentIndex().row()); model->submitAll();}