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)! -
That's ... interesting. Do you have a testcase? Sounds like a bug.
-
I currently can't share my code but I can set up an empty project and try to reproduce the issue.
-
Did you try to set a stretch factor of 1 on both layout elements?
Does the size hint always return the same value?
What are the size policies? -
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 -
Hm, strange. The small test project would be really helpful now :)
-
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.