继承者: QVBoxLayout , QHBoxLayout
PySide.QtGui.QBoxLayout class lines up child widgets horizontally or vertically.
PySide.QtGui.QBoxLayout takes the space it gets (from its parent layout or from the PySide.QtGui.QLayout.parentWidget() ), divides it up into a row of boxes, and makes each managed widget fill one box.
若 PySide.QtGui.QBoxLayout ‘s orientation is Qt.Horizontal 框按合适尺寸排成一行。每个 Widget (或其它框) 将至少获得其最小尺寸和最多获得其最大尺寸。任何多余空间根据拉伸因子共享 (下文有关这更多)。
若 PySide.QtGui.QBoxLayout ‘s orientation is Qt.Vertical ,框被放置在列中,再采用合适尺寸。
The easiest way to create a PySide.QtGui.QBoxLayout is to use one of the convenience classes, e.g. PySide.QtGui.QHBoxLayout (for Qt.Horizontal 框) 或 PySide.QtGui.QVBoxLayout (for Qt.Vertical boxes). You can also use the PySide.QtGui.QBoxLayout constructor directly, specifying its direction as LeftToRight , RightToLeft , TopToBottom ,或 BottomToTop .
若 PySide.QtGui.QBoxLayout is not the top-level layout (i.e. it is not managing all of the widget's area and children), you must add it to its parent layout before you can do anything with it. The normal way to add a layout is by calling parentLayout-> PySide.QtGui.QBoxLayout.addLayout() .
Once you have done this, you can add boxes to the PySide.QtGui.QBoxLayout using one of four functions:
使用 PySide.QtGui.QBoxLayout.insertWidget() , PySide.QtGui.QBoxLayout.insertSpacing() , PySide.QtGui.QBoxLayout.insertStretch() or PySide.QtGui.QBoxLayout.insertLayout() to insert a box at a specified position in the layout.
PySide.QtGui.QBoxLayout also includes two margin widths:
边距默认由样式提供。大多数 Qt 样式指定的默认边距对于 Widget 为 9,对于窗口为 11。间距默认与顶层布局边距宽度相同,或与父布局相同。
要从布局移除 Widget,调用 PySide.QtGui.QLayout.removeWidget() 。调用 QWidget.hide() on a widget also effectively removes the widget from the layout until QWidget.show() 被调用。
几乎总是想要使用 PySide.QtGui.QVBoxLayout and PySide.QtGui.QHBoxLayout 而不是 PySide.QtGui.QBoxLayout because of their convenient constructors.
| 参数: |
|
|---|
构造新 PySide.QtGui.QBoxLayout with direction dir 和父级 Widget parent .
此类型用于确定框布局的方向。
| 常量 | 描述 |
|---|---|
| QBoxLayout.LeftToRight | 水平从左到右。 |
| QBoxLayout.RightToLeft | 水平从右到左。 |
| QBoxLayout.TopToBottom | 垂直从上到下。 |
| QBoxLayout.BottomToTop | 垂直从下到上。 |
| 参数: |
|
|---|
添加 layout 到方框末尾,采用连续拉伸因子 stretch .
另请参阅
PySide.QtGui.QBoxLayout.insertLayout() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QBoxLayout.addWidget()
| 参数: | spacerItem – PySide.QtGui.QSpacerItem |
|---|
添加 spacerItem 到此方框布局的末尾。
| 参数: | size – PySide.QtCore.int |
|---|
添加不可拉伸空间 ( PySide.QtGui.QSpacerItem ) 采用尺寸 size 到此方框布局的末尾。 PySide.QtGui.QBoxLayout 提供默认边距和间距。此函数添加额外空间。
另请参阅
PySide.QtGui.QBoxLayout.insertSpacing() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QSpacerItem
| 参数: | stretch – PySide.QtCore.int |
|---|
添加可拉伸空间 ( PySide.QtGui.QSpacerItem ) with zero minimum size and stretch factor stretch 到此方框布局的末尾。
另请参阅
PySide.QtGui.QBoxLayout.insertStretch() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QSpacerItem
| 参数: | arg__1 – PySide.QtCore.int |
|---|
Limits the perpendicular dimension of the box (e.g. height if the box is LeftToRight ) to a minimum of size . Other constraints may increase the limit.
另请参阅
PySide.QtGui.QBoxLayout.addItem()
| 参数: |
|
|---|
| 返回类型: | PySide.QtGui.QBoxLayout.Direction |
|---|
返回框的方向。 PySide.QtGui.QBoxLayout.addWidget() and PySide.QtGui.QBoxLayout.addSpacing() work in this direction; the stretch stretches in this direction.
另请参阅
PySide.QtGui.QBoxLayout.setDirection() QBoxLayout.Direction PySide.QtGui.QBoxLayout.addWidget() PySide.QtGui.QBoxLayout.addSpacing()
| 参数: |
|
|---|
插入 item 到此框布局在位置 index 。若 index 为负,项被添加在末尾。
另请参阅
PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QBoxLayout.insertWidget() PySide.QtGui.QBoxLayout.insertLayout() PySide.QtGui.QBoxLayout.insertStretch() PySide.QtGui.QBoxLayout.insertSpacing()
| 参数: |
|
|---|
插入 layout 在位置 index ,采用拉伸因子 stretch 。若 index 为负,布局被添加在末尾。
layout 变为框布局的子级。
| 参数: |
|
|---|
插入 spacerItem 在位置 index , with zero minimum size and stretch factor. If index 为负,空间被添加在末尾。
| 参数: |
|
|---|
插入不可拉伸空间 ( PySide.QtGui.QSpacerItem ) 在位置 index ,采用尺寸 size 。若 index 为负,空间被添加在末尾。
框布局具有默认的边距和间距。此函数添加额外空间。
| 参数: |
|
|---|
插入可拉伸空间 ( PySide.QtGui.QSpacerItem ) 在位置 index ,采用 0 最小尺寸和拉伸因子 stretch 。若 index 为负,空间被添加在末尾。
| 参数: |
|
|---|
| 参数: | arg__1 – PySide.QtGui.QBoxLayout.Direction |
|---|
将此布局的方向设为 direction .
| 参数: |
|
|---|
设置拉伸因子在位置 index . to stretch .
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
设置拉伸因子为 widget to stretch and returns true if widget is found in this layout (not including child layouts); otherwise returns false.
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
这是重载函数。
设置拉伸因子为布局 layout to stretch and returns true if layout is found in this layout (not including child layouts); otherwise returns false.
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.int |
返回拉伸因子在位置 index .