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. Remove spacing / margin / border between Widgets

Remove spacing / margin / border between Widgets

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 9.6k 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
    gde23
    wrote on 20 Mar 2018, 14:47 last edited by
    #1

    Hello,

    how can i remove the spacing between widgets?

    alt text

    One case is between the nested widgets (blue arrow - QTabWidget inside a QDockWidget)
    The other case is between neighboring widgets (red arrow - QDockWidget side to side another QDockWidget)

    i have tried setting all the margins /spacing to zero as well as setting the border by stylesheet, but the space does not go away

    layout->setSpacing(0);
    layout->setMargin(0);
    layout->setContentsMargins (0, 0, 0, 0);
    widget->setStyleSheet("border: 0px");
    

    The optimal case would be that the border lines merge into one single line in both cases.

    R D 2 Replies Last reply 20 Mar 2018, 18:16
    1
    • G gde23
      20 Mar 2018, 14:47

      Hello,

      how can i remove the spacing between widgets?

      alt text

      One case is between the nested widgets (blue arrow - QTabWidget inside a QDockWidget)
      The other case is between neighboring widgets (red arrow - QDockWidget side to side another QDockWidget)

      i have tried setting all the margins /spacing to zero as well as setting the border by stylesheet, but the space does not go away

      layout->setSpacing(0);
      layout->setMargin(0);
      layout->setContentsMargins (0, 0, 0, 0);
      widget->setStyleSheet("border: 0px");
      

      The optimal case would be that the border lines merge into one single line in both cases.

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 20 Mar 2018, 18:16 last edited by raven-worx
      #2

      @gde23
      those are the borders of the widget. Those are drawn by the specific platform style.
      You can use stylesheets to remove the borders (and also set the background). e.g. QWidget { border: 0; background: white; }
      But probably you want to do it specifically for certain widegts.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3
      • G gde23
        20 Mar 2018, 14:47

        Hello,

        how can i remove the spacing between widgets?

        alt text

        One case is between the nested widgets (blue arrow - QTabWidget inside a QDockWidget)
        The other case is between neighboring widgets (red arrow - QDockWidget side to side another QDockWidget)

        i have tried setting all the margins /spacing to zero as well as setting the border by stylesheet, but the space does not go away

        layout->setSpacing(0);
        layout->setMargin(0);
        layout->setContentsMargins (0, 0, 0, 0);
        widget->setStyleSheet("border: 0px");
        

        The optimal case would be that the border lines merge into one single line in both cases.

        D Offline
        D Offline
        Diracsbracket
        wrote on 20 Mar 2018, 18:23 last edited by Diracsbracket
        #3

        @gde23
        When you use a QDockWidget, you automatically get a splitter when it is docked, so that you can resize it. It is this splitter that gives you the space between the dock and the other partition of your layout.
        You can change the size of this splitter (called a separator in this context) using a stylesheet on the MainWindow (here this, as I did it in the constructor of MainWindow).
        Along with the border setting on the QTabWidget pane element, this gives:

        ui->tabWidget->setStyleSheet("QTabWidget::pane { border: 0; }");
        this->setStyleSheet("QMainWindow::separator {width: 1px; border: none;}");
        

        You need at least 1px otherwise you can't resize the dock.

        The result on my system is:

        0_1521570026042_05d348f9-2d5d-4729-80da-60dbb43384d1-image.png

        1 Reply Last reply
        3

        2/3

        20 Mar 2018, 18:16

        • Login

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