Important: Please read the Qt Code of Conduct -

Efficiently remove row from QML TableView attached to QSqlTableModel

  • Hello QT world,

    My team and I have been struggling to remove a row from our QSqlTableModel. I know that to refresh the model, select() must be called. However, this is not an option for us, because it is slow (even with an in-memory database) and it loses the user's scroll position. We manually handle deletion from the database (with an ORM we are using), so we really just want to remove the row from the model cache. It would also be acceptable to hide the row in the TableView if the view retained the correct mapping of indices. Does anyone have a solution for this? We have been tearing our hair out for weeks.


  • For anyone still having this problem the solution was to use a QSortFilterProxyModel in front of the QSqlTableModel and filter the deleted rows.

Log in to reply