窗户里的PySide去除角落里的填充物

2024-04-25 04:14:03 发布

您现在位置:Python中文网/ 问答频道 /正文

例如,如果我将QStatusBar添加到我的窗口,我会看到太宽的角:

self.stat = QtGui.QStatusBar()       
widLayout = QtGui.QVBoxLayout()
widLayout.addWidget(some_pannel)
widLayout.addWidget(self.stat)
self.setLayout(widLayout)

enter image description here


Tags: selfsomestat我会qtguiqvboxlayoutaddwidgetsetlayout
1条回答
网友
1楼 · 发布于 2024-04-25 04:14:03

official documentation

  • PySide.QtGui.QLayout.setContentsMargins() sets the width of the outer border on each side of the widget. This is the width of the reserved space along each of the PySide.QtGui.QBoxLayout ‘s four sides.
  • PySide.QtGui.QBoxLayout.setSpacing() sets the width between neighboring boxes. (You can use PySide.QtGui.QBoxLayout.addSpacing() to get more space at a particular spot.)

所以,基本上:

widLayout.setSpacing(0)
widLayout.setContentsMargins(0, 0, 0, 0)

相关问题 更多 >