QScrollArea and QVBoxLayout issues with dynamically added widgets
-
Im running into a weird issue with dynamically added widgets to a QVBoxLayout contained inside a QScrollArea. If I add the widgets it works as expected, however after all widgets are removed, there are still some left overs on the screen. Is this a bug? Can someone else reproduce it?
"Screenshot":http://i.stack.imgur.com/5yK8p.png
"Here is a small project to reproduce it":https://github.com/dryajov/testscrollarea.git
-
@
delete ui->verticalLayout->takeAt(0);
@
is not enough to also remove the widgets.You should do this:
@
QLayoutItem *child;
while ((child = layout->takeAt(0)) != 0)
{
delete child->widget();
delete child;
}
@ -
That seems to have done it. The important bit seems to be:
delete child->widget;
Because I did try deleting just the LayoutItem in my work project.
Thanks!