Skip to content
Advertisement

How to delete row/rows from a qtableview in pyqt?

I am using QStandardItemModel for my qtableview.

JavaScript

here when I am trying to delete the row selected(i.e. model.removeRow() ) I am getting a error” TypeError: argument 1 of QAbstractItemModel.removeRow() has an invalid type”.

I have searched a lot for the correct way of deleting a selected row/rows in qtableview of pyqt. However, I am not able to delete the selected row/rows.

Can you please share a sample code for deleting selected row/rows in qtableview of pyqt?

Advertisement

Answer

the method model.removeRow(index.row()) removes the row selected.

JavaScript

in the indices variable we get the selected row, then we delete the row.

For deleting multiple rows in our selection of tableview:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement