Python Forum
[PyQt] QVBoxLayout default (minimum) size
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] QVBoxLayout default (minimum) size
#2
According to the Qt documentation, layouts contentsMargins are usually 11, not 9.

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)
Reply


Messages In This Thread
QVBoxLayout default (minimum) size - by malonn - Oct-09-2022, 11:10 AM
RE: QVBoxLayout default (minimum) size - by deanhystad - Oct-10-2022, 03:17 AM
RE: QVBoxLayout default (minimum) size - by malonn - Oct-10-2022, 10:56 AM
RE: QVBoxLayout default (minimum) size - by malonn - Oct-13-2022, 04:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Trying to change font size w/o changing button size python63 3 9,969 Aug-05-2020, 01:04 AM
Last Post: Larz60+
  PyGtk3 why is Locale Folder Size Half of Module Size ? harun2525 1 3,667 Mar-09-2017, 03:46 AM
Last Post: Analyser

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020