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.
-
Thanks... but I need behavior (with the same set of controls) as I subscribed above.
I just simplify my real case in this example to show the behavior that I need to get.p.s.
I tried use the spacer but in this case splitter does not work. -
sorry I previously missed qsplitter messing around ;-)
You could use something like this
@ui->frame->setMaximumHeight(b ? 99999 : ui->pushButton->height());@
or
@ui->frame->setMaximumHeight(b ? 99999 : 0);@
if you set frame's minimumSize
-
It's work!
Thanks a lot!