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
Forum Updated to NodeBB v4.3 + New Features

[solved]QVBoxLayout spaces between widgets

Scheduled Pinned Locked Moved General and Desktop
layoutwidgetsspace
3 Posts 2 Posters 11.8k Views 2 Watching
  • 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.
  • GiorgiG Offline
    GiorgiG Offline
    Giorgi
    wrote on last edited by Giorgi
    #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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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

      GiorgiG 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

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

        should do the trick

        GiorgiG Offline
        GiorgiG Offline
        Giorgi
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

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