Results 1 to 4 of 4

Thread: How to add space b/w column and rows of gridlayout.

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default How to add space b/w column and rows of gridlayout.

    Hi
    I am trying to add space b/w rows and column of gridlayout but it is not working.
    I have 2*2 gridlayout like the following

    Qt Code:
    1. QGridLayout *layout = new QGridLayout;
    2. layout->setAlignment(Qt::AlignCenter);
    3.  
    4. layout->addWidget(button_panic, 0, 0);
    5. layout->setHorizontalSpacing(5);
    6. layout->addWidget(button_gas, 0, 1);
    7. layout->setVerticalSpacing(5);
    8. layout->addWidget(button_alarm, 2, 0);
    9. layout->setHorizontalSpacing(5);
    10. layout->addWidget(button_fire, 2, 1);
    11. this->setLayout(layout);
    To copy to clipboard, switch view to plain text mode 

    How to add space b/w widgeta laid in layout.

  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: How to add space b/w column and rows of gridlayout.

    Qt Code:
    1. QGridLayout *layout = new QGridLayout;
    2. layout->setAlignment(Qt::AlignCenter);
    3.  
    4. layout->addWidget(button_panic, 0, 0);
    5. layout->addWidget(button_gas, 0, 1);
    6. layout->addWidget(button_alarm, 1, 0); //check the row number
    7. layout->addWidget(button_fire, 1, 1);
    8.  
    9. layout->setSpacing(50);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to add space b/w column and rows of gridlayout.

    I am assuming that "b/w" means between.

    QGridLayout::setHorizontalSpacing() and QGridLayout::setVerticalSpacing(), which you are already using, set the space between adjacent widgets in the grid. You are asking for 5 pixels between rows and 5 pixels between columns. What is "not working" ?

  4. #4
    Join Date
    Apr 2011
    Posts
    36
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to add space b/w column and rows of gridlayout.

    hi,

    ur code is correct.its working.
    may i know the error u got?

Similar Threads

  1. QTableView empty space or too little space.
    By davemar in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2009, 17:00
  2. Replies: 1
    Last Post: 26th July 2009, 16:08
  3. How to drop space in GridLayout ?
    By jackm in forum Qt Tools
    Replies: 2
    Last Post: 3rd October 2008, 04:06
  4. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 9th March 2006, 00:11
  5. does gridlayout really lay out?
    By illuzioner in forum Newbie
    Replies: 2
    Last Post: 26th February 2006, 01:57

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.