Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.11.0
-
None
-
c18a91b0dc5e82c0624758a6300f561e36b968fc
Description
- 1. Create a QTableWidget instance.
2. Create an item at, say, coordinates column 5, row 3.
3. Hook up a slot to cellChanged signal of the table widget.
3. Call takeItem() with the same coordinates.
Expected: the slot gets invoked with row = 3, column = 5
Actual: it does get invoked, but row and column are set to -1
Per my understanding here is why (from qtablewidget.cpp):
QTableWidgetItem *QTableModel::takeItem(int row, int column) { long i = tableIndex(row, column); QTableWidgetItem *itm = tableItems.value(i); if (itm) { itm->view = 0; itm->d->id = -1; tableItems[i] = 0; QModelIndex ind = index(itm); emit dataChanged(ind, ind); } return itm; }
Note that itm is taken from tableItems vector, then both are modified to essentially forget about each other, and then ind = index(itm) looks back into tableItems vector to find the item, naturally doesn't find anything and returns QModelIndex(), i.e. a default constructor, and sends that to the dataChanged signal.