Results 1 to 8 of 8

Thread: Layout automatically adjusting the space dynamically

  1. #1
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Question Layout automatically adjusting the space dynamically

    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!!

    Qt Code:
    1. connect( ui.emaillineEdit, SIGNAL(textChanged(const QString&)),
    2. this, SLOT(updatefieldWidth(const QString&)));
    3. ...
    4. ...
    5.  
    6. //updatefieldWidth(const QString&) slot code
    7. nWidth += 15;
    8.  
    9. this->ui.emaillineEdit->setGeometry( ui.emaillineEdit->geometry().x(),
    10. ui.emaillineEdit->geometry().y(), nWidth, ui.emaillineEdit->geometry().height() );
    To copy to clipboard, switch view to plain text mode 

    Please find the attached image below,

    Layout1.JPG
    Thanks,
    Nikhil
    Last edited by nikhilqt; 26th May 2011 at 11:56.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Layout automatically adjusting the space dynamically

    place all you widgets in a layout (like QGridLayout / QHBoxLayout etc), then the layout will take care of adjusting the other widgets

  3. #3
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Layout automatically adjusting the space dynamically

    Quote Originally Posted by Santosh Reddy View Post
    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.

  4. #4
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Layout automatically adjusting the space dynamically

    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)?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Layout automatically adjusting the space dynamically

    Quote Originally Posted by nikhilqt View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    nikhilqt (27th May 2011)

  7. #6
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Layout automatically adjusting the space dynamically

    Quote Originally Posted by MarekR22 View Post
    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)

    Quote Originally Posted by wysota View Post
    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 ?

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Layout automatically adjusting the space dynamically

    You change the sizeHint or the minimumWidth of the line edit.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Layout automatically adjusting the space dynamically

    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.

Similar Threads

  1. Hiding Layout item - Layout does not use available space
    By Asperamanca in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2011, 09:51
  2. How to fill a QFrame space in QSplitter layout
    By henryjoye in forum Qt Programming
    Replies: 2
    Last Post: 12th October 2010, 05:18
  3. Dynamically change the layout
    By pippo42 in forum Qt Programming
    Replies: 2
    Last Post: 12th November 2009, 13:01
  4. Layout not giving space equally
    By gruszczy in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2009, 22:49
  5. Qt layout space + stretch
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2007, 15:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.