Results 1 to 4 of 4

Thread: Layout Management Issues

  1. #1
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Layout Management Issues

    How can I control the space between layout and widgets inside a parent layout?

    I have a QVBoxLayout. Inside there are a QLabel and a QGridLayout and another QLabel. As the widget start everything works fine. but when I change the widget size - QT put the all additional vertical space before and after the QGridLayout.

    I think it happens because QVBoxLayout act towards the QGridLayout as if it is just another widget. So QVBoxLayout keeps same space between the three widget it has: QLabel, QGridLayout and QLabel.

    My Question is: How do make it react to the widgets QGridLayout hosts? so I will have even spacing between all the widget in the form?

    Thanks
    Dave

  2. #2
    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 Management Issues

    I'm not sure what exactly the problem is. Could you provide a minimal compilable example which demonstrates the problem? Maybe the solution is to have a 0 margin in the child layout? This way only the parent layout and all the spacings would have an effect.

  3. #3
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Layout Management Issues

    I've given up on using both layout. Now I'm only using one grid layout. This is the code to set it up:
    Qt Code:
    1. void LSysEdge::setupWidget()
    2. {
    3. title = new QLabel("LSystem\nEdge Rewriting Based");
    4. title->setTextFormat(Qt::RichText);
    5. title->setAlignment(Qt::AlignHCenter);
    6.  
    7. initL = new QLabel("&Initiator");
    8. init = new QLineEdit();
    9. initL->setBuddy(init);
    10. init->setValidator(new LSEdgeValidator(init));
    11.  
    12. ruleFL = new QLabel("Production &F");
    13. ruleF = new QLineEdit();
    14. ruleFL->setBuddy(ruleF);
    15. ruleF->setValidator(new LSEdgeValidator(ruleF));
    16.  
    17. rulefL = new QLabel("Production &f");
    18. rulef = new QLineEdit();
    19. rulefL->setBuddy(rulef);
    20. rulef->setValidator(new LSEdgeValidator(rulef));
    21.  
    22. angleL = new QLabel("&Angle");
    23. angle = new QLineEdit();
    24. angleL->setBuddy(angle);
    25. angle->setValidator(new QIntValidator(0, 90, angle));
    26. angle->setMaximumWidth(20);
    27.  
    28. stepsL = new QLabel("&Steps");
    29. steps = new QLineEdit();
    30. stepsL->setBuddy(steps);
    31. steps->setValidator(new QIntValidator(1, 9999, steps));
    32. steps->setMaximumWidth(35);
    33.  
    34. create = new QPushButton("&Create");
    35.  
    36. connect(create, SIGNAL(clicked()),
    37. this, SLOT(createClicked()));
    38. }
    39.  
    40.  
    41. void LSysEdge::setupLayouts()
    42. {
    43. mainLayout = new QGridLayout;
    44.  
    45. mainLayout->addWidget(title, 0, 0, 1, 4);
    46.  
    47. mainLayout->addWidget(initL, 1, 0, 1, 1);
    48. mainLayout->addWidget(init, 1, 1, 1, 3);
    49.  
    50. mainLayout->addWidget(ruleFL, 2, 0, 1, 1);
    51. mainLayout->addWidget(ruleF, 2, 1, 1, 3);
    52.  
    53. mainLayout->addWidget(rulefL, 3, 0, 1, 1);
    54. mainLayout->addWidget(rulef, 3, 1, 1, 3);
    55.  
    56. mainLayout->addWidget(angleL, 4, 0);
    57. mainLayout->addWidget(angle, 4, 1);
    58.  
    59. mainLayout->addWidget(stepsL, 5, 0);
    60. mainLayout->addWidget(steps, 5, 1);
    61.  
    62. mainLayout->addWidget(create, 6, 1, 1, 1);
    63.  
    64. setLayout(mainLayout);
    65.  
    66. init->setFocus();
    67. }
    To copy to clipboard, switch view to plain text mode 

    The problem is that if I try to resize the widget height, all the available space go between the first QLabel and all the other widgets. the space between all the other widgets don't change at all.

  4. #4
    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 Management Issues

    Then you probably have to use different size policies. Especially the one from the label.

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 21:21
  2. QtDesigner Layout Help
    By mentat in forum Qt Tools
    Replies: 5
    Last Post: 13th July 2006, 15:55
  3. Layout issues
    By vijay anandh in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2006, 20:27
  4. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 08:16
  5. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 20: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.