Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Padding between QMainWindow and contained widgets

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

Padding between edges

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

I tried to increase padding with QSS stylesheet:

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

but got some really unexpected result:

Unexpected result

I tried calling setContentsMargins method, but it actually changes the margins around the central widget just as the method's name says.

How can I increse padding between QMainWindow and contained widgets? Is there a way to change it with QSS?

like image 241
ezpresso Avatar asked Jan 13 '15 15:01

ezpresso


1 Answers

You would need to put them all in another container and then set that container to be the central widget. Then you can call container.setContentsMargins()

like image 114
Supamee Avatar answered Sep 20 '22 04:09

Supamee