我有一个 Qt4 应用程序,它有很多对话框。我很想知道 QDialog 是否删除了它的布局。举个例子:
class MyDialog : public QDialog {
public:
MyDialog(QWidget* _parent = 0) : QDialog(_parent) {
//instantiate some widgets
m_layout = new QGridLayout(this);
setLayout(m_layout)
//add some widgets to the layout
}
~MyDialog() {
//Do I need this code? or will the parent delete the layout?
//delete m_layout;
}
private:
QGridLayout* m_layout;
}
那么我需要编写自己的析构函数吗?还是 QDialog 会负责m_layout的内存管理?