PDA

View Full Version : Adjusting Widget size in a QGridLayout



Max Yaffe
30th July 2007, 22:52
Dear Denizons of QtCenterForum/Programming:

Is there any simple way to adjust the relative sizes (spans) of Widgets in a QGridLayout? I'd like to be able to increment or decrement the spans from some signal, e.g. a context menu.

I looked at the code in the DynamicLayouts example and it looks like they removed all the widgets and then added them back again readjusted. That means the window has to maintain another list of the widgets. That seems clumsy.

Any better approach known out there?

Thanks,
Max

marcel
30th July 2007, 23:03
Write your own layout and add smart updating to it.
As a result of that signal you just tell the layout you want some widget to span across 3 cells, not one as it originally was.

Otherwise maybe you can work something out with setRowStretch and setColumnStretch.



I looked at the code in the DynamicLayouts example and it looks like they removed all the widgets and then added them back again readjusted. That means the window has to maintain another list of the widgets. That seems clumsy.

No, you just take the widgets out, create another layout and add them in the new layout, which you set in place of the old one.

Regards