Inherited by: QVBoxLayout, QHBoxLayout
The 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.
If the PySide.QtGui.QBoxLayout ‘s orientation is Qt.Horizontal the boxes are placed in a row, with suitable sizes. Each widget (or other box) will get at least its minimum size and at most its maximum size. Any excess space is shared according to the stretch factors (more about that below).
If the PySide.QtGui.QBoxLayout ‘s orientation is Qt.Vertical , the boxes are placed in a column, again with suitable sizes.
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 boxes) or PySide.QtGui.QVBoxLayout (for Qt.Vertical boxes). You can also use the PySide.QtGui.QBoxLayout constructor directly, specifying its direction as LeftToRight , RightToLeft , TopToBottom , or BottomToTop .
If the 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.addWidget() to add a widget to the PySide.QtGui.QBoxLayout and set the widget’s stretch factor. (The stretch factor is along the row of boxes.)
- PySide.QtGui.QBoxLayout.addSpacing() to create an empty box; this is one of the functions you use to create nice and spacious dialogs. See below for ways to set margins.
- PySide.QtGui.QBoxLayout.addStretch() to create an empty, stretchable box.
- PySide.QtGui.QBoxLayout.addLayout() to add a box containing another PySide.QtGui.QLayout to the row and set that layout’s stretch factor.
Use 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:
- 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.)
The margin default is provided by the style. The default margin most Qt styles specify is 9 for child widgets and 11 for windows. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout.
To remove a widget from a layout, call PySide.QtGui.QLayout.removeWidget() . Calling QWidget.hide() on a widget also effectively removes the widget from the layout until QWidget.show() is called.
You will almost always want to use PySide.QtGui.QVBoxLayout and PySide.QtGui.QHBoxLayout rather than PySide.QtGui.QBoxLayout because of their convenient constructors.
See also
PySide.QtGui.QGridLayout PySide.QtGui.QStackedLayout Layout Management
Parameters: |
|
---|
Constructs a new PySide.QtGui.QBoxLayout with direction dir and parent widget parent .
See also
This type is used to determine the direction of a box layout.
Constant | Description |
---|---|
QBoxLayout.LeftToRight | Horizontal from left to right. |
QBoxLayout.RightToLeft | Horizontal from right to left. |
QBoxLayout.TopToBottom | Vertical from top to bottom. |
QBoxLayout.BottomToTop | Vertical from bottom to top. |
Parameters: |
|
---|
Adds layout to the end of the box, with serial stretch factor stretch .
See also
PySide.QtGui.QBoxLayout.insertLayout() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QBoxLayout.addWidget()
Parameters: | spacerItem – PySide.QtGui.QSpacerItem |
---|
Adds spacerItem to the end of this box layout.
Parameters: | size – PySide.QtCore.int |
---|
Adds a non-stretchable space (a PySide.QtGui.QSpacerItem ) with size size to the end of this box layout. PySide.QtGui.QBoxLayout provides default margin and spacing. This function adds additional space.
See also
PySide.QtGui.QBoxLayout.insertSpacing() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QSpacerItem
Parameters: | stretch – PySide.QtCore.int |
---|
Adds a stretchable space (a PySide.QtGui.QSpacerItem ) with zero minimum size and stretch factor stretch to the end of this box layout.
See also
PySide.QtGui.QBoxLayout.insertStretch() PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QSpacerItem
Parameters: | 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.
See also
PySide.QtGui.QBoxLayout.addItem()
Parameters: |
|
---|
Return type: | PySide.QtGui.QBoxLayout.Direction |
---|
Returns the direction of the box. PySide.QtGui.QBoxLayout.addWidget() and PySide.QtGui.QBoxLayout.addSpacing() work in this direction; the stretch stretches in this direction.
See also
PySide.QtGui.QBoxLayout.setDirection() QBoxLayout.Direction PySide.QtGui.QBoxLayout.addWidget() PySide.QtGui.QBoxLayout.addSpacing()
Parameters: |
|
---|
Inserts item into this box layout at position index . If index is negative, the item is added at the end.
See also
PySide.QtGui.QBoxLayout.addItem() PySide.QtGui.QBoxLayout.insertWidget() PySide.QtGui.QBoxLayout.insertLayout() PySide.QtGui.QBoxLayout.insertStretch() PySide.QtGui.QBoxLayout.insertSpacing()
Parameters: |
|
---|
Inserts layout at position index , with stretch factor stretch . If index is negative, the layout is added at the end.
layout becomes a child of the box layout.
Parameters: |
|
---|
Inserts spacerItem at position index , with zero minimum size and stretch factor. If index is negative the space is added at the end.
Parameters: |
|
---|
Inserts a non-stretchable space (a PySide.QtGui.QSpacerItem ) at position index , with size size . If index is negative the space is added at the end.
The box layout has default margin and spacing. This function adds additional space.
Parameters: |
|
---|
Inserts a stretchable space (a PySide.QtGui.QSpacerItem ) at position index , with zero minimum size and stretch factor stretch . If index is negative the space is added at the end.
Parameters: |
|
---|
Parameters: | arg__1 – PySide.QtGui.QBoxLayout.Direction |
---|
Sets the direction of this layout to direction .
See also
Parameters: |
|
---|
Sets the stretch factor at position index . to stretch .
See also
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Sets the stretch factor for widget to stretch and returns true if widget is found in this layout (not including child layouts); otherwise returns false.
See also
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
This is an overloaded function.
Sets the stretch factor for the layout layout to stretch and returns true if layout is found in this layout (not including child layouts); otherwise returns false.
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.int |
Returns the stretch factor at position index .
See also