Results 1 to 2 of 2

Thread: QGroupBox expands to maximum in BoxLayout

  1. #1
    Join Date
    Feb 2009
    Posts
    79
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    11
    Thanked 5 Times in 5 Posts

    Default QGroupBox expands to maximum in BoxLayout

    Hi!

    I have added a QGoupBox to my QVBoxLayout.
    The QGroupBox itself also holds a QVBoxLayout.

    Qt Code:
    1. QVBoxLayout * outer = new QVBoxLayout;
    2. outer->addWidget(new QPushButton("A"));
    3. outer->addWidget(new QPushButton("B"));
    4.  
    5. QGroupBox * box = new QGroupBox("title");
    6. QVBoxLayout * inner = new QVBoxLayout;
    7. inner->addWidget(new QRadioButton("Poss A"));
    8. inner->addWidget(new QRadioButton("Poss B"));
    9. box->setLayout(inner);
    10. box->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); //doesn't help :-(
    11. outer->addWidget(box);
    12.  
    13. outer->addWidget(new QPushButton("C"));
    14. outer->addWidget(new QPushButton("D"));
    To copy to clipboard, switch view to plain text mode 

    In this example, the QPushButtons automatically have "unit" height, but are horizontally expanded to maximum width.

    The GroupBox also expands to maximal height, which I do not want.

    So, my concern is to find a way, s.t. the group box only takes as much space as it really needs to display its contents, i.e. the two QRadioButtons.

    Thank you for your help in advance,
    Best regards,
    Oliver

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: QGroupBox expands to maximum in BoxLayout

    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. The maximum size of a QList
    By Denarius in forum Newbie
    Replies: 3
    Last Post: 30th November 2012, 11:27
  2. Maximum Speed Needed
    By lixo1 in forum Qt Programming
    Replies: 35
    Last Post: 22nd March 2009, 23:27
  3. Replies: 2
    Last Post: 12th January 2009, 00:24
  4. Axis's minimum and maximum
    By pankaj.patil in forum Qwt
    Replies: 4
    Last Post: 16th June 2008, 22:38
  5. maximum size of xml files
    By freeskydiver in forum Qt Programming
    Replies: 1
    Last Post: 15th January 2008, 11:02

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
  •  
Qt is a trademark of The Qt Company.