[Qt-interest] Dynamic Layout Management

Shawn Badger shawnbadger at gmail.com
Tue Dec 29 00:26:06 CET 2009


On Mon, Dec 28, 2009 at 1:02 PM, Shawn Badger <shawnbadger at gmail.com> 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?
>
> Thanks,
> Shawn
>

Ok, I ended up figuring out a way to do this.  Rather than show #1
then hide #2, I reversed the order of operations to hide #2 and then
show #1.  This works exactly as I had hoped.  I'm not sure why Qt
behaves differently in the two cases.  They seem like equivalent
operations to me.

Shawn




More information about the Qt-interest-old mailing list