CAD DCLQLayout* layout = ui.scrollAreaWidgetContents->layout(); for(int i = 0; i < layout->count(); ++i) { QLayoutItem* item = layout->itemAt(i); if(item) { layout->removeItem( item ); QWidget* widget = item->widget(); if(widget) { layout->removeWidget(widget); delete widget; } delete item; } }
C++ (Qt)QLayoutItem * QLayout::takeAt ( int index ) [pure virtual]
C++ (Qt)while(layout->count()){ QLayoutItem * item = layout->itemAt(0);...}
C++ (Qt)while( (item = layout->itemAt(0)) ) { layout->removeItem( item ); layout->removeWidget(item->widget()); delete item; }
C++ (Qt) while( (item = layout->itemAt(0)) ) { layout->removeItem( item ); layout->removeWidget(item->widget()); delete item->widget(); delete item; layout->update(); }
C++ (Qt)while( (item = layout->itemAt(0)) ) { layout->removeItem( item ); layout->removeWidget(item->widget()); //delete item->widget(); delete item; layout->update(); }
//btnVBoxLayout - глобальная переменная, тип QVBoxLayout QVBoxLayout * mainVBoxLayout = new QVBoxLayout(); QLabel * tstLabel = new QLabel("Тут могла быть ваша реклама :)", this); mainVBoxLayout->addWidget(tstLabel); mainVBoxLayout->addLayout(btnVBoxLayout); QHBoxLayout * bottomHBoxLayout = new QHBoxLayout(); bottomHBoxLayout->addWidget(btnBack); bottomHBoxLayout->addWidget(btnRefresh); mainVBoxLayout->addLayout(bottomHBoxLayout); setLayout(mainVBoxLayout);