Filling between QMainWindow and contained widgets

I am trying to increase the padding between widgets contained in a QMainWidget and the edges of a QMainWidget. You can see this problem in the image below:

Padding between edges

There is no padding between the QTabWidget (which is the central QMainWidget widget) and the left edge of the main window. There is also no padding between QDockWidgets and the right edge of the main window.

I tried to increase padding using the QSS stylesheet:

QMainWindow { padding: 10px; margin: 10px; border: 5px solid red; } 

but got some really unexpected result:

Unexpected result

I tried calling the setContentsMargins method, but it actually changes the fields around the center widget, as the method name says.

How can I add an add-on between QMainWindow and the contained widgets? Is there a way to change it using QSS?

+7
c ++ qt qt5 qmainwindow qss
source share
1 answer

You will need to put them all in another container, and then set this container as the main widget. Then you can call container.setContentsMargins ()

+1
source share

All Articles