1
votes

i have to update or change the widget inside the scrollArea depending on the selection of tree items in left.

 QWidget *scrollAreaWidget = new QWidget;

    scrollAreaWidget->setObjectName("ScrollAreaWidget");

    QVBoxLayout *scrollLayout = new QVBoxLayout;
    scrollAreaWidget->setLayout(scrollLayout);
    foreach (PyInfo pInfo, list) {
        //Adding widget
        rowWidget->setObjectName(objName);
            scrollLayout->addWidget(rowWidget);

    }
    m_pScrollArea->setWidget(scrollAreaWidget);

so when i need to update a new widget i tried to clear the old widget added to scrollArea like this

QWidget *wid = m_pScrollArea->widget();

    if(wid)
        wid->deleteLater();

is deleteLated() call is enough or i have to explicitly delete all the widgets i added as a child to the ScrollArea->widget() and disconnect my signals in it.

1

1 Answers

1
votes

Yes, this should be enough. Qt takes care about the rest. From Qt documentation:

The parent takes ownership of the object; i.e., it will automatically delete its children in its destructor.

......

A signal-slot connection is removed when either of the objects involved are destroyed.