Reputation: 364
How better to realize adding and deleting items in a custom model for QTableView, which are working via MVC?
By adding custom functions to model: add() and delete(...)?
Just implement function update() and add directly elements in list attached with this QTableView.
Upvotes: 0
Views: 294
Reputation: 326
I'd say it depends on the nature of your model:
If your model is holding the data to be shown itself, providing custom methods like add(const Data &data)
and remove()
is a common solution - just be sure to call beginInsertRows
/endInsertRows
and beginRemoveRows
/endRemoveRows
inside those methods.
If you directly access the data storage (List/Map/Whatever), it should be sufficient to just call insertRow
/removeRow
after adding new data.
Upvotes: 2