Update QTableView after remove a row
-
I have some Rows in a QTableView I add them using QSqlTableModel
now I use this code to remove the selected rowint r = ui->tableView->selectionModel()->currentIndex().row(); ui->tableView->model()->removeRow(r);
but nothing happend i want to update the view how can i do that as when i use this code the row still found but when i press Save button it edit my database table and remove it but not from the view.
Thanks in advance. -
i add the select to the model after the remove but nothing happend
int r = ui->tableView->selectionModel()->currentIndex().row(); ui->tableView->model()->removeRow(r); model->select();
the row still found but it take no number it not count when i select a row and press remove button which have the above function it make a question mark beside this row and remove it's number between the rows
when i press the save button which contains this codeif(model->submitAll()) model->database().commit(); else model->database().rollback(); QMessageBox::information(this, "Done", "Data saved!");
it starts to take the effect and remove the row from the tableview i asked how to remove it without press the save button and let it show in the tableview if this possible.
-
Sorry, I forgot about the submission part. If you don't want to have to press that other button, then you have to submit your change in the function that removes the row.
-
I use QSqlTableModel::OnFieldChange Edit strategy and then model->select(); and it works fine
if I use OnManualSubmit Edit strategy the same things happens and I think it's in the model's design and not a BUG, so I guess if you need to change that behavior you have to subclass. -
I have some Rows in a QTableView I add them using QSqlTableModel
now I use this code to remove the selected rowint r = ui->tableView->selectionModel()->currentIndex().row(); ui->tableView->model()->removeRow(r);
but nothing happend i want to update the view how can i do that as when i use this code the row still found but when i press Save button it edit my database table and remove it but not from the view.
Thanks in advance.