How to delete all cells in a pyqt4 table widget?

Suppose I have a pyqt4 table widget, for example:

self.table = QtGui.QTableWidget(3,4)

With self.table.clear()I can delete the entire contents of the table. However, how can I delete all the cells in a table, not just the content?

+5
source share
2 answers

Alternatively, you can set the number of rows and columns:

self.table.setRowCount(0)
self.table.setColumnCount(0)
+10
source

Not tried, but you can try:

for i in reversed(range(self.table.rowCount())):
    self.table.removeRow(i)
+3
source

All Articles