Instead of manually managing memory, you can let the compiler do this for you. At this point, you may ask: why use a bunch at all? You should keep things as costly as possible and let the compiler do the hard work.
Objects will be destroyed in the reverse order of declaration. Thus, first - the implicit parent - must be declared first so that he does not try to incorrectly remove his children. In C ++, the order of declarations makes sense!
int main(int argc, char* argv[])
{
QApplication app(argc,argv);
QSplitter splitter;
QTreeView tree;
QListView list;
QTableView table;
splitter.addWidget(&tree);
splitter.addWidget(&list);
splitter.addWidget(&table);
splitter.show();
return app.exec();
}
source
share