Remove qwidget from QT layout

I have a qwidget (we will call it qwidget1) inside the layout of another qwidget (let's call it qwidget2), I want to delete everything that is in qwidget2 layout: I would like to clear the layout so that there is nothing else in it. what can i do so far, completely remove qwidget2 by doing:

void QCell::deleteMyChildren(){ delete this; } 

but it removes qwidget2 itself .. this is not what I want. Please help me remove the elements inside the layout.

+2
qt layout qwidget
Jan 29 '13 at 14:18
source share
1 answer

just loop inside the elements in the layout and remove the element from the layout, and then remove the element:

 void QCell::deleteMyChildren() { while (count() > 0) { QLayoutItem * item = takeAt(0); delete item; } } 
+2
Jan 29 '13 at 16:31
source share



All Articles