diff options
authorChristian Ehrlicher <>2020-01-31 20:51:03 +0100
committerChristian Ehrlicher <>2020-02-21 20:04:21 +0100
commit1559c328d536ceb8b7f78892a60aced4716b40b6 (patch)
parent3c20b9b97377172dd1fc384bd28d3c7dbff0f523 (diff)
QTableWidget: avoid complete redrawing when an item is removed
When an item gets removed from QTableWidget, the dataChanged() signal is sent out with an invalid index. This triggers a complete repaint which is not needed since only one cell is changed. Fix it by retrieving the model index *before* the internal structure is cleaned for the given item since otherwise index() will no longer find the item and return an invalid index. Change-Id: Ia0d82edb6b44118e8a1546904250ca29d9c45140 Reviewed-by: Friedemann Kleint <>
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 60abd02564..7b1f1a1caf 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -247,8 +247,8 @@ void QTableModel::removeItem(QTableWidgetItem *item)
int i = tableItems.indexOf(item);
if (i != -1) {
- tableItems[i] = 0;
QModelIndex idx = index(item);
+ tableItems[i] = nullptr;
emit dataChanged(idx, idx);