0

I have a table which has below data:

enter image description here

I want to remove all the data from the rows and just want to keep the headers i.e. Person Name, Number of Photos Enrolled and Gallery. How can I do this in pyqt5 python. Below is the code I tried but seems not to working:

 for item in self.home_ui.show_person_gallery_table.selectedItems():
     new_item = self.home_ui.show_person_gallery_table.item()
     self.home_ui.show_person_gallery_table.setItem(item.row(), item.column(), new_item)
S Andrew
  • 5,592
  • 27
  • 115
  • 237

1 Answers1

3

one way that you can remove all rows is set table rows count zero like following code.

   self.home_ui.show_person_gallery_table.setRowCount(0)

for more info about QTableWidget visit this web site https://doc.qt.io/qt-5/qtablewidget.html