Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all cells in a pyqt4 tablewidget?

Tags:

python

pyqt4

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?

like image 365
student Avatar asked May 30 '12 18:05

student


2 Answers

Alternatively, you can set the row and column counts:

self.table.setRowCount(0)
self.table.setColumnCount(0)
like image 140
Avaris Avatar answered Oct 21 '22 04:10

Avaris


Haven't tried it, but you can try:

for i in reversed(range(self.table.rowCount())):
    self.table.removeRow(i)
like image 31
iTayb Avatar answered Oct 21 '22 06:10

iTayb