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:
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:
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?
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With