I have such a code and I wonder how should I clean up after it? Should I delete all elements one by one? Should I delete also layouts? Or can I delete just the main element - parent of every other and hope that he will clean up the rest of them?

Qt Code:
  1. TableTab::TableTab(QWidget *parent) :
  2. QWidget(parent)
  3. {
  4. objectNameLabel_ = new QLabel;
  5. personLabel_ = new QLabel;
  6. tableWidget_ = new RequestTable(parent);
  7. summaryBox_ = new QGroupBox;
  8. commentaryTextEdit_ = new QPlainTextEdit;
  9. normatywLabel_ = new QLabel;
  10. sumLabel_ = new QLabel;
  11. reInvoiceLabel_ = new QLabel;
  12. QGroupBox *calculationsBox = new QGroupBox;
  13.  
  14. objectNameLabel_->setText("OBIEKT 1");
  15. personLabel_->setText("JOLA");
  16. normatywLabel_->setText("666");
  17. sumLabel_->setText("667");
  18. reInvoiceLabel_->setText("668");
  19.  
  20. QBoxLayout *layout = new QVBoxLayout;
  21. layout->addWidget(normatywLabel_);
  22. layout->addWidget(sumLabel_);
  23. layout->addWidget(reInvoiceLabel_);
  24. calculationsBox->setLayout(layout);
  25.  
  26. layout = new QHBoxLayout;
  27. layout->addWidget(commentaryTextEdit_);
  28. layout->addWidget(calculationsBox);
  29. summaryBox_->setLayout(layout);
  30.  
  31. layout = new QVBoxLayout;
  32. layout->addWidget(objectNameLabel_);
  33. layout->addWidget(personLabel_);
  34. layout->addWidget(tableWidget_);
  35. layout->addWidget(summaryBox_);
  36. setLayout(layout);
  37. }
To copy to clipboard, switch view to plain text mode