所以我对Qt的内存管理有点困惑.我正在查看开始的示例和教程并看到了这一点
QApplication app(argc, argv);
QWidget window;
QLabel *label = new QLabel(QApplication::translate("windowlayout", "Name:"));
QLineEdit *lineEdit = new QLineEdit();
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget(label);
layout->addWidget(lineEdit);
window.setLayout(layout);
window.setWindowTitle(
QApplication::translate("windowlayout", "Window layout"));
window.show();
return app.exec();
Run Code Online (Sandbox Code Playgroud)
哪个是好的,除了我在创建新小部件时没有看到任何内存释放,现在这只是为了教程,所以他们不会混淆人或者是由Qt自动处理的内存管理.因为看着这个,我不得不相信存在内存泄漏,因为没有任何东西被释放.