student
student

Reputation: 1646

How to remove all cells in a pyqt4 tablewidget?

Suppose I have a pyqt4 table widget, for example:

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

With self.table.clear() I can remove all contents of the table. However how can I delete all cells of the table, not only the content?

Upvotes: 6

Views: 9992

Answers (2)

Avaris
Avaris

Reputation: 36715

Alternatively, you can set the row and column counts:

self.table.setRowCount(0)
self.table.setColumnCount(0)

Upvotes: 14

iTayb
iTayb

Reputation: 12743

Haven't tried it, but you can try:

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

Upvotes: 4

Related Questions