[Qt-interest] Dynamic QGridLayout
Sean Harmer
sean.harmer at maps-technology.com
Fri Feb 27 09:09:53 CET 2009
On Friday 27 February 2009 07:59:34 Luper Rouch wrote:
> Hello,
>
> I have a two columns set of widgets in a QGridLayout. I would like the
> layout to rearrange properly when I show or hide widgets in it. Right
> now if I hide things in it I get "holes" in the columns, here is an
> ASCII art explanation :
>
> Before:
> * *
> * *
>
> After hiding (0, 0) and (1, 1):
> *
> *
>
> But I would like to get this:
> * *
>
> How can I do that ?
By keeping track of how many rows and cols you have and when a row or column
becomes empty move the remaining visible items into new locations in the grid
so that it doesn't have "holes". You could even derive a class from
QGridLayout that does this for you automatically so that it is nicely
encapsulated and tailored to your exact needs.
Sean
More information about the Qt-interest-old
mailing list