Results 1 to 4 of 4

Thread: add small space in a grid layout

  1. #1
    Join Date
    Aug 2013
    Posts
    41
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default add small space in a grid layout

    Hi,

    How can I add small variable space within a column in a grid layout?
    (as in sub-bullets in MS office).

    I have 5 QCheckBoxes. 3,4,5 are sub boxes of 2.

    Please look at the attached picture(1pic.jpg).
    Attached Images Attached Images

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: add small space in a grid layout

    Try to use QSpacerItem.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Aug 2013
    Posts
    41
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: add small space in a grid layout

    I tried it. But I could not achieve the desired result. Following is the sample code:

    Qt Code:
    1. QVBoxLayout *MySubLayout = new QVBoxLayout(this);
    2. QGroupBox *MyGroupBox = new QGroupBox(tr("Group:1"));
    3. QGridLayout *MyGridLayout = new QGridLayout(this);
    4.  
    5. QCheckBox *Chek1 = new QCheckBox(tr("Check1")); //main checkbox1
    6. QCheckBox *Chek2 = new QCheckBox(tr("Check2")); // main checkbox2
    7.  
    8. QCheckBox *Chek3 = new QCheckBox(tr("Check3")); //sub checkbox1
    9. QCheckBox *Chek4 = new QCheckBox(tr("Check4")); //sub checkbox2
    10.  
    11. MyGroupBox->setLayout(MyGridLayout);
    12.  
    13. OutputLayout->addWidget(Chek1,1,0);
    14. OutputLayout->addWidget(Chek2,2,0);
    15. OutputLayout->addWidget(Chek3,3,0); // space required before this checkbox
    16. OutputLayout->addWidget(Chek4,4,0); //space required before this checkbox
    17.  
    18. MySubLayout->addWidget(MyGroupBox);
    To copy to clipboard, switch view to plain text mode 

    Please indicate how can I add space as illustrated in the 1pic.jpg. Thanks

  4. #4
    Join Date
    Aug 2013
    Posts
    41
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: add small space in a grid layout

    @Spirit: could u plz indicate where can I insert QSpacerItem in the above lines to get the desired result as shown in the pic?

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. Replies: 0
    Last Post: 2nd April 2008, 07:48
  3. Qt layout space + stretch
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2007, 15:53
  4. How do I layout in a Grid?
    By DPinLV in forum Qt Tools
    Replies: 7
    Last Post: 10th August 2006, 01:37
  5. Grid layout
    By nupul in forum Qt Programming
    Replies: 7
    Last Post: 21st April 2006, 21:15

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.