[英]How to remove all cells in a pyqt4 tablewidget?
Suppose I have a pyqt4 table widget, for example: 假设我有一个pyqt4表小部件,例如:
self.table = QtGui.QTableWidget(3,4)
With self.table.clear()
I can remove all contents of the table. 使用
self.table.clear()
我可以删除表的所有内容。 However how can I delete all cells of the table, not only the content? 但是,如何删除表中的所有单元格,而不仅仅是内容?
Alternatively, you can set the row and column counts: 或者,您可以设置行数和列数:
self.table.setRowCount(0)
self.table.setColumnCount(0)
Haven't tried it, but you can try: 没试过,但你可以尝试:
for i in reversed(range(self.table.rowCount())):
self.table.removeRow(i)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.