Reputation: 763
I have a layout that contain other layout (sublayout). I need to remove sublayout with content from layout. How i can do it?
QVBoxLayout* mainLayout = new QVBoxLayout;
QHBoxLayout* subLayout = new QHBoxLayout;
for(int i = 0; i < 3; i++)
subLayout->addWidget(new QPushButton(this)); //some content of sublayout
mainLayout->addLayout(subLayout);
setLayout(mainLayout);
There are only QLayout::removeWidget()
, but not something like QLayout::removeLayout()
in this class. Just
delete subLayout
or
QLayoutItem *item;
while ((item = subLayout->takeAt(0)))
delete item;
delete subLayout;
have no correct effect too (Content still remains on the screen).
So how?
Upvotes: 0
Views: 372
Reputation: 49289
void QLayout::removeItem(QLayoutItem *item)
Removes the layout item item from the layout. It is the caller's responsibility to delete the item.
Notice that item can be a layout (since QLayout inherits QLayoutItem).
Upvotes: 2