Unexpected behavior when hiding and showing widgets in a layout
-
Dear Qt users:
I have two identical widgets in an horizontal layout and I added buttons that allows showing and hiding them.
Before I added this buttons, my widgets used to always have the same size.
Now I have a strange issue, when I hide and reshow one widget, I don't get a 50%-50% width but something like 30-70%.Do I need to call something on the parent layout, right after changing the visibility status of the widgets?
!http://pix.wefrag.com/i/b/7/e/d/b/44501b9c2364b5cb4f169c594def2d16.png(example)! -
I currently can't share my code but I can set up an empty project and try to reproduce the issue.
-
When I set a stretch factor of 1, the remaining widget does not expand in the empty space leaved by the hidden one.
Size policies are MinimumExpanding for both widgets and the layoutSizeConstraint of the parent layout is set to SetMaximumSize -
I'm now hiding elements like this:
@ for( int i=0; i< ui->resultLayout->count(); ++i )
ui->resultLayout->itemAt(i)->widget()->setVisible(false);
@
and it works like expected. I will update this thread if I have any new issue.