Add this in the beginning of the slot (i assume ui->horizontalLayout_2 does not have anything else, other than the layout you add)
Qt Code:
void analysis::on_pushButton_clicked() { QLayoutItem *child; while ((child = ui->horizontalLayout_2->takeAt(0)) != 0) { delete child; } .... }To copy to clipboard, switch view to plain text mode
Bookmarks