Thank you for your reply.
Unfortunately the proposed correction doesn't solve the problem.
If I omit "flowlayout->update()" nothing in my program changes after I press the delete button (all Buttons remain in the flowlayout and all buttons still work). If I add "flowlayout->update()" to your correction, the program behaviour is the same as explained in the top post.
I tried a bit more and now I have the behaviour I aimed for with:
void MyWidget::deleteButton() {
if( item )
{
item->widget()->hide();
delete item->widget();
delete item;
}
qDebug() <<"deleted: "<<flowlayout->count();
}
void MyWidget::deleteButton() {
QLayoutItem *item = flowlayout->takeAt(0);
if( item )
{
item->widget()->hide();
delete item->widget();
delete item;
}
qDebug() <<"deleted: "<<flowlayout->count();
}
To copy to clipboard, switch view to plain text mode
delete item->widget(); makes the button disappear from the layout.
item->widget()->hide(); makes sure that the buttons that are left get rearranged.
Bookmarks