void AttributeEditor::clear() { if (m_parent->layout()) { clear_layout(m_parent->layout()); delete m_parent->layout(); } }
void DisneyMaterialLayerUI::unfold() { // Show the layer's content. m_content_widget->setVisible(true); // Hide the layer's name in the header. clear_layout(m_header_widget->layout()); // Update the icon of the fold/unfold button. m_fold_unfold_button->setIcon(m_fold_icon); }
void clear_layout(QLayout* layout) { for (int i = layout->count(); i > 0; --i) { QLayoutItem* item = layout->takeAt(0); if (item->layout()) clear_layout(item->layout()); else item->widget()->deleteLater(); delete item; } }
// Completely clear out a layout. // Use recursion to clear out layouts inside of layouts void clear_layout(QLayout* layout) { // Paranoia - Layout doesn't exist. if (!layout) return; while (QLayoutItem* item = layout->takeAt(0)) { if (QWidget* widget = item->widget()) delete widget; if (QLayout* childLayout = item->layout()) { clear_layout(childLayout); } delete item; } }