문제

Say I have something like this

void someClass::start()
{
    QLabel* sb = new QLabel();
    sb->setText("Hello World");
    ui.verticalLayout->addWidget(sb);
}

Does addWidget make sb a child of someClass so that when I delete someClass sb is also deleted ? If this is true how do I know which methods in general assign parents to an object ?

도움이 되었습니까?

해결책

From http://qt-project.org/doc/qt-4.8/layout.html:

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top