QAbstractItemView: Make sure to update the editor geometries
QAbstractItemView::setIndexWidget() does not trigger a relayouting when a new widget is set. This results in a wrong editor geometry under some circumstances. Fix it by triggering a delayed relayout. Fixes: QTBUG-81763 Change-Id: I75d0e19bd5e56d63effe4990d782d202fb39e3e6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
835e18d9ff
commit
875420f1c2
@ -3234,8 +3234,10 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget
|
||||
widget->installEventFilter(this);
|
||||
widget->show();
|
||||
dataChanged(index, index); // update the geometry
|
||||
if (!d->delayedPendingLayout)
|
||||
if (!d->delayedPendingLayout) {
|
||||
widget->setGeometry(visualRect(index));
|
||||
d->doDelayedItemsLayout(); // relayout due to updated geometry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -952,6 +952,7 @@ void tst_QTreeView::indexWidget()
|
||||
QStandardItemModel treeModel;
|
||||
initStandardTreeModel(&treeModel);
|
||||
view.setModel(&treeModel);
|
||||
view.resize(300, 400); // make sure the width of the view is larger than the widgets below
|
||||
|
||||
QModelIndex index = view.model()->index(0, 0);
|
||||
|
||||
@ -980,6 +981,7 @@ void tst_QTreeView::indexWidget()
|
||||
|
||||
//now let's try to do that later when the widget is already shown
|
||||
view.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
index = view.model()->index(1, 0);
|
||||
QVERIFY(!view.indexWidget(index));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user