Oct-10-2022, 03:17 AM
(This post was last modified: Oct-10-2022, 04:09 PM by deanhystad.)
According to the Qt documentation, layouts contentsMargins are usually 11, not 9.
https://doc.qt.io/qt-6/qlayout.html#setContentsMargins
I wrote a little test and this appears to be true for PySide6.
https://doc.qt.io/qt-6/qlayout.html#setContentsMargins
Quote:By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.This is inherited from the base class QLayout, so I would expect it to be the same for all layout managers unless changed by a style.
I wrote a little test and this appears to be true for PySide6.
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QGridLayout, QPushButton class Box(QWidget): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) layout = QVBoxLayout(self) print(layout.contentsMargins(), layout.minimumSize()) class Grid(QWidget): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) layout = QGridLayout(self) print(layout.contentsMargins(), layout.minimumSize()) app = QApplication() box = Box() grid = Grid() box.show() grid.show() app.exec()
Output:<PySide6.QtCore.QMargins(11, 11, 11, 11) at 0x000001F1DEB4E380> PySide6.QtCore.QSize(22, 22)
<PySide6.QtCore.QMargins(11, 11, 11, 11) at 0x000001F1DEB4E440> PySide6.QtCore.QSize(22, 22)