比尔盖子
比尔盖子

Reputation: 3617

How do I remove a (sub) layout item from QVBoxLayout?

I found a lot of answers about removing widget from QVBoxLayout.

But I didn't find out any answer about removing a layout. I know I can put my sub-layout into a QWidget. I just want to know something more.

layout = QtGui.QVBoxLayout()
item_in_layout = create_layout()
layout.addLayout(item_in_layout)
# Remove?

Upvotes: 6

Views: 5521

Answers (2)

Pavel Strakhov
Pavel Strakhov

Reputation: 40492

Use QLayout::itemAt to obtain the corresponding layout item and QLayout::removeItem to remove it.

Upvotes: 0

Zlatomir
Zlatomir

Reputation: 7034

Use removeItem with the pointer to the layout you want to remove.

Upvotes: 4

Related Questions