• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QFormLayout

    下一话题

    QVBoxLayout

    QBoxLayout

    继承者: 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.

    ../../_images/qhboxlayout-with-5-children.png

    PySide.QtGui.QBoxLayout ‘s orientation is Qt.Horizontal 框按合适尺寸排成一行。每个 Widget (或其它框) 将至少获得其最小尺寸和最多获得其最大尺寸。任何多余空间根据拉伸因子共享 (下文有关这更多)。

    ../../_images/qvboxlayout-with-5-children.png

    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.

    class PySide.QtGui. QBoxLayout ( arg__1 [ , parent=None ] )
    参数:

    构造新 PySide.QtGui.QBoxLayout with direction dir 和父级 Widget parent .

    PySide.QtGui.QBoxLayout. Direction

    此类型用于确定框布局的方向。

    常量 描述
    QBoxLayout.LeftToRight 水平从左到右。
    QBoxLayout.RightToLeft 水平从右到左。
    QBoxLayout.TopToBottom 垂直从上到下。
    QBoxLayout.BottomToTop 垂直从下到上。
    PySide.QtGui.QBoxLayout. addLayout ( layout [ , stretch=0 ] )
    参数:

    添加 layout 到方框末尾,采用连续拉伸因子 stretch .

    PySide.QtGui.QBoxLayout. addSpacerItem ( spacerItem )
    参数: spacerItem PySide.QtGui.QSpacerItem

    添加 spacerItem 到此方框布局的末尾。

    PySide.QtGui.QBoxLayout. addSpacing ( size )
    参数: size PySide.QtCore.int

    添加不可拉伸空间 ( PySide.QtGui.QSpacerItem ) 采用尺寸 size 到此方框布局的末尾。 PySide.QtGui.QBoxLayout 提供默认边距和间距。此函数添加额外空间。

    另请参阅

    PySide.QtGui.QBoxLayout.insertSpacing() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QSpacerItem

    PySide.QtGui.QBoxLayout. addStretch ( [ stretch=0 ] )
    参数: 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

    PySide.QtGui.QBoxLayout. addStrut ( arg__1 )
    参数: 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. addWidget ( arg__1 [ , stretch=0 [ , alignment=0 ] ] )
    参数:
    PySide.QtGui.QBoxLayout. direction ( )
    返回类型: 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. insertItem ( index , arg__2 )
    参数:

    插入 item 到此框布局在位置 index 。若 index 为负,项被添加在末尾。

    PySide.QtGui.QBoxLayout. insertLayout ( index , layout [ , stretch=0 ] )
    参数:

    插入 layout 在位置 index ,采用拉伸因子 stretch 。若 index 为负,布局被添加在末尾。

    layout 变为框布局的子级。

    PySide.QtGui.QBoxLayout. insertSpacerItem ( index , spacerItem )
    参数:

    插入 spacerItem 在位置 index , with zero minimum size and stretch factor. If index 为负,空间被添加在末尾。

    PySide.QtGui.QBoxLayout. insertSpacing ( index , size )
    参数:
    • index PySide.QtCore.int
    • size PySide.QtCore.int

    插入不可拉伸空间 ( PySide.QtGui.QSpacerItem ) 在位置 index ,采用尺寸 size 。若 index 为负,空间被添加在末尾。

    框布局具有默认的边距和间距。此函数添加额外空间。

    PySide.QtGui.QBoxLayout. insertStretch ( index [ , stretch=0 ] )
    参数:
    • index PySide.QtCore.int
    • stretch PySide.QtCore.int

    插入可拉伸空间 ( PySide.QtGui.QSpacerItem ) 在位置 index ,采用 0 最小尺寸和拉伸因子 stretch 。若 index 为负,空间被添加在末尾。

    PySide.QtGui.QBoxLayout. insertWidget ( index , widget [ , stretch=0 [ , alignment=0 ] ] )
    参数:
    • index PySide.QtCore.int
    • widget PySide.QtGui.QWidget
    • stretch PySide.QtCore.int
    • alignment PySide.QtCore.Qt.Alignment
    PySide.QtGui.QBoxLayout. setDirection ( arg__1 )
    参数: arg__1 PySide.QtGui.QBoxLayout.Direction

    将此布局的方向设为 direction .

    PySide.QtGui.QBoxLayout. setStretch ( index , stretch )
    参数:
    • index PySide.QtCore.int
    • stretch PySide.QtCore.int

    设置拉伸因子在位置 index . to stretch .

    PySide.QtGui.QBoxLayout. setStretchFactor ( w , 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.QtGui.QBoxLayout. setStretchFactor ( l , stretch )
    参数:
    返回类型:

    PySide.QtCore.bool

    这是重载函数。

    设置拉伸因子为布局 layout to stretch and returns true if layout is found in this layout (not including child layouts); otherwise returns false.

    PySide.QtGui.QBoxLayout. stretch ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.int

    返回拉伸因子在位置 index .