[Qt-interest] Dynamic QGridLayout
Luper Rouch
luper.rouch at gmail.com
Fri Feb 27 10:02:42 CET 2009
Sean Harmer a écrit :
> 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
>
Going column by column and shifting items up sounds like overkill to me.
I think I will adapt the FlowLayout from the examples.
Thanks,
Luper
More information about the Qt-interest-old
mailing list