Search code examples
qtqt4qlistview

qt: remove item from QListView


How do I remove an item from a QListView? For QComboBox it's removeItem but I can't find an equivalent function for QListView.

Using pyqt4.


Solution

  • In QListWidget you can remove directly with takeAt(), but not in QListView (read Qt Model/View). You should use the widget unless you need your own model. If QListView is what you want then get model, and remove, i.e. qListView.model().removeRow(row)