diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-01-31 20:51:03 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-02-21 20:04:21 +0100 |
commit | 1559c328d536ceb8b7f78892a60aced4716b40b6 (patch) | |
tree | 37bafee4b5e4d155389501a9f4ab420d6fa102ba /src/widgets | |
parent | 3c20b9b97377172dd1fc384bd28d3c7dbff0f523 (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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtablewidget.cpp | 2 |
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); return; } |