Delete row in QML TableView or all rows
Solved
QML and Qt Quick
-
@Babs Hi,
TableView doesn't own the data, that's the role of the model. So you need to delete content from the model.
ListModel { id: libraryModel ListElement { title: "A Masterpiece" author: "Gabriel" } ListElement { title: "Brilliance" author: "Jens" } ListElement { title: "Outstanding" author: "Frederik" } } TableView { TableViewColumn { role: "title" title: "Title" width: 100 } TableViewColumn { role: "author" title: "Author" width: 200 } model: libraryModel } Button{ onClicked: { if(libraryModel.count > 1) libraryModel.remove(0) //remove first row in the model } }