I want to clear my QTableWidget.
First of all, I select the user in qcombobox after that, I press the qpushbutton button, and I populate it from the database entries; when I select another user and I press the qpush button to add the data that I am trying to clear with:
self.tableFriends.clear()
The data disappears, but the rows remain.
The code I fill out is:
def getFriends(self):
id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject()
rowIndex = 0
self.tableFriends.clear()
for row in self.SELECT_FRIENDS(id_us):
self.tableFriends.insertRow(rowIndex)
for column in range(0,3):
newItem = QtGui.QTableWidgetItem(str(row[column]).decode('utf-8'))
self.tableFriends.setItem(rowIndex,column,newItem)
rowIndex = rowIndex + 1
source
share