Answer the question
In order to leave comments, you need to log in
Why ASSERT: "!isEmpty()"?
when a row is selected in the tableview, the code works, the deletion occurs.
and when selecting one cell, it throws an error:
ASSERT: "!isEmpty()" in file C:/Qt/5.8/mingw53_32/include/QtCore/qlist.h, line 344
this line:
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
QSqlQueryModel *setquery1 = new QSqlQueryModel;
QSqlTableModel *model = new QSqlTableModel;
QItemSelectionModel *selectModel = ui->tableView->selectionModel();
if (selectModel->hasSelection())
{
int nr = selectModel->selectedRows().first().row();
ui->dir_excel->setText(ui->tableView->model()->data(ui->tableView->model()->index(nr,0)).toString());
if (QMessageBox::Yes == QMessageBox::question(this, "Удалить?",
"Уверены?",
QMessageBox::Yes|QMessageBox::No))
{
ui->dir_excel->setText(ui->tableView->model()->data(ui->tableView->model()->index(nr,0)).toString());
QString indid = ui->tableView->model()->data(ui->tableView->model()->index(nr,0)).toString();
setquery1->setQuery("DELETE FROM ships WHERE id="+indid+";");
model->setTable("ships");
model->select();
ui->tableView->setModel(model);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question