PDA

View Full Version : Simple frame control doesn't resize when I hide()



MrGarbage
29th August 2007, 20:16
Can someone please help me with this?

I have received and researched several soultions to this seemingly simple task
without finding a working one.

I have a widget. It consists of a frame which contains some text and
a button. Click on the button and the text disappears and the
frame resizes to show only the button. Click on the button and the
text reappears and the frame expands to it's previous size.

This widget lives alone in a GroupBox on an existing form.
It is not a top level widget.
For now I don't care whether the form resizes or not, I just want the
above functionality..

No matter what I try, the text disappears but the frame refuses to
resize.

Several people have indicated that

layout()->setSizeConstraint(QLayout::SetFixedSize);

is the answer. I've tried that, I believe that is only true for top level (ie Dialogs)
widgets.

I've attached a simple.ui file.


many thanks...
Mark

marcel
29th August 2007, 20:25
The size policies of the group box should be "expanding".

Otherwise, you can use setFixedSize(sizeHint()) on the group box after you hide the label. You also must use it when showing the label.

BTW, that UI is not useful by itself. There is nothing to be tested.

Regards

MrGarbage
29th August 2007, 22:32
I must be an idiot but this continues to be a problem for me.
The attached ui resizes as I would like in QT Designer preview.

I then add code in my test app to act on the button click and hide the HiddenText area.

The FrameGroup does not resize down. It is set to Expanding,Expanding and
has a minimum size of 20,44.

I want the OuterGroup to remain fixed in size. Similarly I want the FrameGrouo
to not be resizeable, except when the button click occurs.

Perhaps I don't understand who controls who in the layout process...

This is driving me nuts!

Mark