Qt & Qt Designer - Making widget fill the parent without padding

Aaron picture Aaron · Jun 12, 2013 · Viewed 19.7k times · Source

I wanted to make my widget fill the parent window, even when the window resizes, so I read this: How to make a Qt Widget grow with the window size?

But this solution created a new problem: my widget automatically re-sizes to the size of the window, but there's padding on the sides of the window. I want the widget to completely fill the parent, and it's not doing that. Look:



Here you can see that the tab widget doesn't entirely fill the parent. I've done some research and have seen that through programming, you can configure the layout to get rid of this padding. Problem is, I'm building my GUI in QDesigner, so I can't just go layout->setMargin(0);

My question is, how to I get rid of this padding on the sides of my window through Qt Designer?

Answer

Amartel picture Amartel · Jun 12, 2013

In the bottom of central widget properties there is a section of Layout (it is red), where you can set layout margins. Also, you still can do it programmatically:

QMainWindow::centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);