QML ListView is not updated for removal



  • I have a custom model that is derived from QAbstractListModel and it has a variable (_sqlTableModel) holding an instance of QSqlTableModel. The code is as follows:

    @
    beginResetModel();
    _sqlTableModel->removeRows(index, 1);
    endResetModel();
    @

    The problem that I am seeing is that the view doesn't get refreshed and it still displays the deleted item even though the item is actually removed from the model. This doesn't make sense. Any advice to correct this issue?

    I have similar code with append, insert, and move and everything works fine.

    Thanks for any tip.

    [EDIT: code formatting, Volker]



  • For removing rows you should use beginRemoveRows()\endRemoveRows()



  • Thanks! That works.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.