PDA

View Full Version : How to avoid a widget to be affected by a layout ?



tonnot
19th July 2011, 10:23
I have the typical layout_vertical thats adjust the vertical size of a layout_horizontal whre I have the widgets distributed.
Ok, now I'd want to have a independent widget 'floating' , but I dont know how to do the work. If I set layout_vertical for the main Widget, the floating widget is affected.
Any idea ?
Thanks

Santosh Reddy
19th July 2011, 12:51
if you want the widget to be floating, don't add to the layout, just create the widget with a parent widget (the widget you want to place it on), and call show() to make it visible, and call setGeometry() to set the floating position, which is relative to the parent.

tonnot
19th July 2011, 13:17
Thanks.
The problem is related with Designer.
Ok, I have a pure QWidget.
I have 1.- a List 2.- a Treeview. I want to apply a horizontal layout to this two elements, givin (in example ) 200 pixels max to treeview. I select the 2 components and click on 'layout Horizontally".Ok, my horizontal resize runs ok.

I have my third element, a 'floating' widget that I have placed in no particular place, in example, at the bottom -left.
Next, I want to let automatic vertical resize for my 2 main componentes (the list and the treeview), so on the main Widget I choose layout vertically.

The problem was that this layout is applying to the layout_horizontal and my_floating widget.
And I dont know how to fix this problem ?
The solution can be a bool 'float' property that does not exist. ( to tell layout that a widget with this property set to true is not part of the world to adjust )
Thanks

high_flyer
19th July 2011, 14:37
The solution can be a bool 'float' property that does not exist.
It does exist - explicitly.
As Santosh Reddy already said, if you want a widget not to be managed by a layout, just keep that widget out of a layout, this is your bool - the layout will only manage widgets that are added to it.


so on the main Widget I choose layout vertically.
By this you are adding ALL the widgets on the forum to this layout, including your third widget which until now was not in a layout.
Instead of adding the layout to whole form, selct only the widgets/laouts you want to manage with this layout.