Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]QVBoxLayout spaces between widgets

[solved]QVBoxLayout spaces between widgets

Scheduled Pinned Locked Moved General and Desktop
layoutwidgetsspace
3 Posts 2 Posters 11.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Giorgi
    wrote on 8 May 2015, 20:01 last edited by Giorgi 5 Aug 2015, 20:38
    #1

    Hello

    I have a problem in QVBoxLayout.
    i want to remove space between two widgets.
    here is my code

        QVBoxLayout *layout = new QVBoxLayout(this);
    
        QTextBrowser *browser1 = new QTextBrowser();
        layout->addWidget(browser1);
        QSizePolicy policy;
        policy.setVerticalStretch(1);
        policy.setHorizontalStretch(1);
        policy.setVerticalPolicy(QSizePolicy::Preferred);
        policy.setHorizontalPolicy(QSizePolicy::Preferred);
        browser1->setSizePolicy(policy);
    
        QTextBrowser *browser2 = new QTextBrowser();
        layout->addWidget(browser2);
        QSizePolicy policy1;
        policy1.setVerticalStretch(4);
        policy1.setVerticalPolicy(QSizePolicy::Preferred);
        policy1.setHorizontalPolicy(QSizePolicy::Preferred);
        browser2->setSizePolicy(policy1);
    

    people says about this method

    browser1->setContentsMargins(-1, 0, -1, -1)
    or
    layout ->setContentsMargins(-1, 0, -1, -1)
    but i have not result.

    please help

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 May 2015, 20:08 last edited by
      #2

      Hi,

      layout->setSpacing(0);
      layout->setContentMargin(0, 0, 0, 0);
      

      should do the trick

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 8 May 2015, 20:37
      1
      • S SGaist
        8 May 2015, 20:08

        Hi,

        layout->setSpacing(0);
        layout->setContentMargin(0, 0, 0, 0);
        

        should do the trick

        G Offline
        G Offline
        Giorgi
        wrote on 8 May 2015, 20:37 last edited by
        #3

        @SGaist
        layout->setSpacing(0); was enought. thank you...

        1 Reply Last reply
        0

        1/3

        8 May 2015, 20:01

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved