How does Qt delete objects ? And what is the best way to store QObjects? [duplicate]
This question already has an answer here: Creating and deallocating a Qt widget object 2 answers I heard that objects in Qt will automatically delete their children, I want to know what will happen in those situations. #include <QApplication> #include <QLabel> #include <QHBoxLayout> #include <QWidget> int main(int argc, char **argv) { QApplication app(argc, argv); /* QLabel label("label"); // Program will crash. Destruct order is 1. widget, 2. layout, 3. label QHBoxLayout layout; // But layout will be deleted twice QWidget widget; */ QWidget widget; // Program doesn't seem to crash but is it