[Solved] QTableView (QTableWidget) removeRow removes several rows
-
I have this code:
@
self.connect(table, SIGNAL('cellPressed(int, int)'), self.deleteRowClicked)
....
def deleteRowClicked(self, row, column):
if column == 0:
table = self.sender()
table.removeRow(row)
return True@
So if the user clicks on the cell of the first column the row is removed.
The problem I have is that this code remove not only that row, also all rows behind it. :?
What I'm doing bad???
-
Hi and welcome to devnet,
Are you sure your slot is not called twice rather than removing two rows ?
-
Right now, I don't know. Did you check the row/col values ? Are you keeping the mouse down when pressing your mouse button ?
-
Might be propagating to the next cell since you delete the one under the cursors (that's just an idea nothing more)
Personally, I wouldn't use cellPressed to delete a row, rather cellClicked or cellDoubleClicked.
-
That's a classic :)
Most of the time connections like this one should be done in the widget's constructor