Say I have something like this:
void someClass::start()
{
QLabel* label = new QLabel();
label->setText("Hello World");
ui.verticalLayout->addWidget(label);
}
Does addWidget
make label
a child of someClass
so that when I delete someClass
, label
is also deleted? If this is true, how do I know which methods in general assign parents to an object?
From Qt Documentation — Layout Management — Tips for Using Layouts:
When you use a layout, you do not need to pass a parent when constructing the child widgets. The layout will automatically reparent the widgets (using QWidget::setParent()) so that they are children of the widget on which the layout is installed.