How to clear all widgets in QScrollArea ?
Solved
General and Desktop
-
Why I can not clear all widgets in QScrollArea ?
QLabel *label = new QLabel; label->setText("FIFA"); ui->verticalLayout_shedule->addWidget(label,0,Qt::AlignTop); ... QLayoutItem *child; while ((child = ui->verticalLayout_shedule->takeAt(0)) != 0) { delete child; }
-
Hi
You only take the items out.
the items also contains the actual widget.void MainWindow::on_toolButton_released() { QLayoutItem *child; while ((child = ui->verticalLayout->takeAt(0)) != 0) { delete child->widget(); // get rid of widget too delete child; } }