[Qt-interest] Dynamic Layout Management

Frank Mertens frank at cyblogic.de
Tue Dec 29 16:40:09 CET 2009


Shawn Badger wrote:
> Hi,
> 
> I am running into a problem that I can't seem to find an answer to.
> My scenario is simple.  I have a central widget that contains two
> child widgets in a horizontal layout, like so:
> 
> ------------------------------
> |         |                           |
> |         |                           |
> |    1   |            2             |
> |         |                           |
> |         |                           |
> ------------------------------
> 
> I need the ability to show only widget #1, or #2, or both at the same
> time, and have the window grow/shrink accordingly.  When I hide #1 and
> then call resize(0,0), the window correctly shrinks to the size of #2.
>  And when I show #1, it grows back to the size of #1+#2.  However, if
> I hide #2, I cannot get the window to shrink down to the size of #1.
> It's like the size hint does not get updated correctly.
> 
> Does anyone know how to get the behaviour I am looking for, without
> having to force a fixed geometry?
> 

Yes, Qt4's layout system has bugs.
Maybe try a QSplitter, at least it keeps the sizes correctly
and if it doesn't you can call setSizes().




More information about the Qt-interest-old mailing list