Adjust the parent size when child is hidden
-
I have the following dialog structure:
!http://files.rsdn.ru/38394/dialog_struct.jpg(dialog structure)!It's a splitter with frames where is each frame contain button and scroll area.
When the user uncheck the button the scroll area is hiding. And result is:
!http://files.rsdn.ru/38394/window_splitter.jpg(result)!So the button just aligned on the center of frame.
But I want another behavior like on the following image:
!http://files.rsdn.ru/38394/window_splitter_2.jpg(desired result)!If I understand correctly I just need call adjustSize() for the frame when I hide the scroller:
@void MainWindow::on_btn_1(bool b)
{
ui->scrollArea->setVisible(b);
ui->frame->adjustSize();
}@But unfortunately it's does not work :-(
Thanks."Link to the source code:":http://files.rsdn.ru/38394/QtTest2.zip
-
use QToolBox instead.
just ui->scrollArea->setVisible(b); should work
also remove frame, frame_2, frame_3 and use vertical layout on scrollArea_global. Add vertical spacer at bottom to handle case when all buttons are off.
PS: you don't have to add separate layout on widget. Just right click on control and select layout from there.