Yes, I solved using this code. I hope it destroys all the widgets in myMessageScrollList, will check.
Tell me if it's correct on the GUI side, please.
QGroupBox *oldReceivedPMsBox
= receivedPMsBox;
receivedPMsBox
= new QGroupBox("Received PMs",
this);
myMessageScrollList = new MessageScrollList(account->getUser()->getReceivedPMs(), this);
receivedPMsLayout->addWidget(myMessageScrollList);
receivedPMsBox->setLayout(receivedPMsLayout);
myLayout->removeWidget(oldReceivedPMsBox);
oldReceivedPMsBox->deleteLater();
myLayout->addWidget(receivedPMsBox, 0, 0);
QGroupBox *oldReceivedPMsBox = receivedPMsBox;
receivedPMsBox = new QGroupBox("Received PMs", this);
myMessageScrollList = new MessageScrollList(account->getUser()->getReceivedPMs(), this);
QVBoxLayout *receivedPMsLayout = new QVBoxLayout;
receivedPMsLayout->addWidget(myMessageScrollList);
receivedPMsBox->setLayout(receivedPMsLayout);
myLayout->removeWidget(oldReceivedPMsBox);
oldReceivedPMsBox->deleteLater();
myLayout->addWidget(receivedPMsBox, 0, 0);
To copy to clipboard, switch view to plain text mode
myMessageScrollList is a scrollarea full of MessageWidgets, so I need to destroy a bunch of objects anyway.
Is there something inherently wrong in destroying widgets at runtime?
BTW I have a question about QGroupBox
boxLayout->addWidget(widgetInABox);
messagesBox->setLayout(boxLayout);
messagesBox = new QGroupBox("title", this);
QWidget *widgetInABox = new QWidget;
QVBoxLayout *boxLayout = new QVBOXLayout;
boxLayout->addWidget(widgetInABox);
messagesBox->setLayout(boxLayout);
To copy to clipboard, switch view to plain text mode
Does widgetInABox become a child of messagesBox?
Bookmarks