PDA

View Full Version : Layout automatically adjusting the space dynamically



nikhilqt
26th May 2011, 11:14
Hi,

I have issue in not getting adjusted with the layout controls if any one of the widget in the layout is re-sized dynamically. If i expand one of the widget it even overlays with the adjacent widget too.

Any idea what need to be set to do it working!!


connect( ui.emaillineEdit, SIGNAL(textChanged(const QString&)),
this, SLOT(updatefieldWidth(const QString&)));
...
...

//updatefieldWidth(const QString&) slot code
nWidth += 15;

this->ui.emaillineEdit->setGeometry( ui.emaillineEdit->geometry().x(),
ui.emaillineEdit->geometry().y(), nWidth, ui.emaillineEdit->geometry().height() );


Please find the attached image below,

6478
Thanks,
Nikhil

Santosh Reddy
26th May 2011, 11:25
place all you widgets in a layout (like QGridLayout / QHBoxLayout etc), then the layout will take care of adjusting the other widgets

nikhilqt
26th May 2011, 12:55
place all you widgets in a layout (like QGridLayout / QHBoxLayout etc), then the layout will take care of adjusting the other widgets

Its already in the layout. I think, you haven't read my problem statement. I am claiming here the layout is not resizing dynamically, means if you alter the geometry of the controls in the layout at runtime then the layout is not doing the job.

please see the attached the image in the last post.

MarekR22
26th May 2011, 14:08
If widget is managed by a layout then you are not directly responsible for size changes of this widget, so you short code snippet suggests bad design or bug in your code.
Describe problem with more details: what is changing that should cause resizing? what is (or isn't) in the layout? Expected outcome? How you code looks like (maybe you did some mistakes)?

wysota
26th May 2011, 16:50
Its already in the layout. I think, you haven't read my problem statement.
If your setGeometry() call has any visible effect then the widget is not managed by a layout.

nikhilqt
27th May 2011, 08:22
If widget is managed by a layout then you are not directly responsible for size changes of this widget, so you short code snippet suggests bad design or bug in your code. Describe problem with more details: what is changing that should cause resizing? what is (or isn't) in the layout? Expected outcome? How you code looks like (maybe you did some mistakes)?

The code and the layout everything is working fine. There is no point in bad design or buggy code. Here i want to enter email address, the lineedit should change its width depending on the user entry into the field. So the above code/slot only specifies to increase the lineedit width dynamically.
Expected outcome: 1) increase in the lineedit width(this is happening) 2) Dynamically layout has to adjust the size of the other widgets present in that layout(Not Happening and i want to fix this)


If your setGeometry() call has any visible effect then the widget is not managed by a layout.

oh! Thanks for info. That's what i need. yes, there will be increase in the width of the lineedit and layout has to adjust to size of the other widgets present in it. Then how to achieve it ?

wysota
27th May 2011, 08:43
You change the sizeHint or the minimumWidth of the line edit.

ChrisW67
27th May 2011, 08:49
Don't forget to do something sane when the user's GMail account is I_am_froody_dude_that_always_knows_where_his_towel _is@gmail.com and you have completely crowded out the other widgets in the layout.