[Solved]delete Groupbox, delete linked widgets too?
When I have a QGroupbox with have a layout which have widgets, and I delete the Groupbox, have I to delete the other widgets too or get they automatically deleted?
QVBoxLayout *boxLayout = new QVBoxLayout;
QLabel *label1 = new QLabel;
QLabel *label2 = new QLabel;
QGroupBox *groupBox = new QGroupBox;
Are now label1, label2 and boxLayout deleted too?
Whenever you delete a widget (or any other QObject descendant) all of it's children get deleted too. Layout contents automatically become children of the widget you set that layout on.
If everything has a parent or is part of an assigned layout the only thing you need to delete is the top most widget(except when it is the last remaining widget or has a flag delete on close set, in which case it also gets deleted automatically).