[Solved] How to hide a QBoxLayout and all its content?
I have an interface composed of two QHBoxLayout embedded in a QVBoxLayout. The top QHBoxLayout and its content should remain visible at all time, whereas the bottom QHBoxLayout should be able to toggle hide/show on request from widgets in the top QHBoxLayout. (I hope my description is clear).
I haven't found a hide/show method in QBoxLayout. I tried to set two alternate geometries to the lower QHBoxLayout (height 500 vs. height 0) but the latter didn't change anything -- perhaps because the content of the lower QHBoxLayout is forcing its size to the layout.
How could i achieve this feature? Can i do this with the existing layouts or do i need to derive a new subclass and inherit a show/hide from some other QObject? Ideally i'd like to have an animation on resizing the lower QHBoxLayout, that is I'd like it to resize gradually, possibly with a time-step: so in that case, should the show/hide feature be based on changing the height of the QHBoxLayout?
goblincoding last edited by
I would change my interface so that it is composed of two separate QWidgets, each with its own QHBoxLayout containing whatever your box layouts contain, and then simply call hide()/show() on the widget in question.
Does that make sense or do I need to be more descriptive?
EDIT: I wouldn't know how to make the hiding process happen gradually though...
Ha! it sounds like a nice idea. What you propose in fact, is to use the QWiget as a container. I'm going to see if that works out.
I am also wondering as to whether i could use a QDockWidget with the top Widget as a central widget and the dock to the south of the central widget.
Eddy last edited by
In the official Qt book C++ GUI Programming with Qt 4 there is a chapter explaining what you want: shape changing dialogs.
You can get the book from this page:
Have fun reading it.
Eddy last edited by
I didn't notice this question before
bq. I am also wondering as to whether i could use a QDockWidget with the top Widget as a central widget and the dock to the south of the central widget.
This is possible also.
QDockWidget is what i needed. Thanks.