Fixed bug in QLayout::replaceWidget()
If the \a to widget was already part of a layout it would be removed from the layout. This happened because the function that was supposed to perform this removal was called after we had done the replacement. QLayout::addChildWidget() should therefore be called first. This is also documented in QLayout::addChildWidget() Change-Id: Ie718935a14ebad81827fad962920e930263c05b8 Task-number: QTBUG-37724 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
parent
7dd5726380
commit
d59638f21d
@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
|
||||
if (index == -1)
|
||||
return 0;
|
||||
|
||||
addChildWidget(to);
|
||||
QLayoutItem *newitem = new QWidgetItem(to);
|
||||
newitem->setAlignment(item->alignment());
|
||||
QLayoutItem *r = d->replaceAt(index, newitem);
|
||||
if (!r)
|
||||
delete newitem;
|
||||
else
|
||||
addChildWidget(to);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user