The Qt Tutorial address memory management issues ... concerning Qt widgets.
From the Qt Tutorial -- Chapter 4
"Note that quit is a local variable in the constructor. MyWidget does not keep track of it; Qt does, and will automatically delete it when the MyWidget object is deleted. This is why MyWidget doesn't need a destructor. (On the other hand, there is no harm in deleting a child when you choose to. The child will automatically tell Qt about its imminent death.)"
MyWidget
::MyWidget(QWidget *parent
){
...
quit->setGeometry(62, 40, 75, 30);
...
}
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
...
QPushButton *quit = new QPushButton(tr("Quit"), this);
quit->setGeometry(62, 40, 75, 30);
quit->setFont(QFont("Times", 18, QFont::Bold));
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks