I was looking at the example here, and was wondering if there is no memory leaks. I have red the article talking about the subjet mem leak on delete. However while QWidgets do retain ownership of the of the widget added to the, the layout do not.
It seems from the QT code that the parent with the layout, gets the ownership of all the widgets for this layout. However i could not seen any reference of this in docs.
Window::Window()
{
editor = new QTextEdit();
QPushButton *sendButton = new QPushButton(tr("&Send message"));
connect(sendButton, SIGNAL(clicked()), this, SLOT(sendMessage()));
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addStretch();
buttonLayout->addWidget(sendButton);
buttonLayout->addStretch();
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(editor);
layout->addLayout(buttonLayout);
setWindowTitle(tr("Custom Type Sending"));
}
From Layout Management: