Results 1 to 7 of 7

Thread: Qt layout issue

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Qt layout issue

    Hey there,

    I have an issue with the QVBoxLayout.

    I'm dynamicaly changing widget inside the layout : removing one and inserting another.

    - When the new widgets occupies more space : the layout stretches and everything works fine.

    But,

    - When the new widgets occupies less space than the previous one : the layout doesn't shrink and keep its dimension.

    Any way to force the resize of the layout ?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt layout issue

    Try calling invalidate after adding the widget,

    Regards

  3. #3
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt layout issue

    Thanks,

    Here is my code for my "settable widget" :

    Qt Code:
    1. //=============================================================================
    2. //=============================================================================
    3.  
    4. void ZeSettableWidget::setWidget(QWidget & widget)
    5. {
    6. ClearWidget();
    7.  
    8. mWidget = &widget;
    9.  
    10. mLayout.addWidget(mWidget);
    11. mWidget->show();
    12.  
    13. mLayout.invalidate();
    14. }
    To copy to clipboard, switch view to plain text mode 

    Doesn't seem to work, the layout doesn't shrink back to the smaller widget size.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt layout issue

    Yes, you are right, it will never work like this.
    You have to recreate the layout each time.

    I think there are a few similar threads/

    Regards

  5. #5
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt layout issue

    I'm not sure to know what I'm searching for.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt layout issue

    Qt Code:
    1. layout->setSizeConstraint(QLayout::SetFixedSize);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  7. The following user says thank you to jpn for this useful post:

    bunjee (15th August 2007)

  8. #7
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt layout issue

    Qt Code:
    1. mLayout.setSizeConstraint(QLayout::SetFixedSize);
    To copy to clipboard, switch view to plain text mode 

    worked with me.

    Thanks.

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  2. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 22:54
  3. Qt4 widget and nested layout issue.
    By bunjee in forum Qt Programming
    Replies: 12
    Last Post: 18th January 2007, 20:29
  4. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 07:16
  5. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 19:57

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.