继承者: QStackedLayout , QGridLayout , QFormLayout , QBoxLayout , QVBoxLayout , QHBoxLayout
PySide.QtGui.QLayout class is the base class of geometry managers.
这是被继承的抽象基类,由具体类 PySide.QtGui.QBoxLayout , PySide.QtGui.QGridLayout , PySide.QtGui.QFormLayout ,和 PySide.QtGui.QStackedLayout .
For users of PySide.QtGui.QLayout subclasses or of PySide.QtGui.QMainWindow there is seldom any need to use the basic functions provided by PySide.QtGui.QLayout ,譬如 PySide.QtGui.QLayout.setSizeConstraint() or PySide.QtGui.QLayout.setMenuBar() 。见 布局管理 了解更多信息。
To make your own layout manager, implement the functions PySide.QtGui.QLayout.addItem() , PySide.QtGui.QLayoutItem.sizeHint() , PySide.QtGui.QLayout.setGeometry() , PySide.QtGui.QLayout.itemAt() and PySide.QtGui.QLayout.takeAt() . You should also implement PySide.QtGui.QLayout.minimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement PySide.QtGui.QLayoutItem.hasHeightForWidth() and PySide.QtGui.QLayoutItem.heightForWidth() 。见 Border Layout and Flow Layout examples for more information about implementing custom layout managers.
几何体管理停止,当布局管理器被删除时。
另请参阅
PySide.QtGui.QLayoutItem 布局管理 基本布局范例 边框布局范例 流式布局范例
| 参数: | parent – PySide.QtGui.QWidget |
|---|
Constructs a new child PySide.QtGui.QLayout .
This layout has to be inserted into another layout before geometry management will work.
Constructs a new top-level PySide.QtGui.QLayout ,采用父级 parent . parent may not be 0.
There can be only one top-level layout for a widget. It is returned by QWidget.layout() .
可能的值:
| 常量 | 描述 |
|---|---|
| QLayout.SetDefaultConstraint | The main widget's minimum size is set to PySide.QtGui.QLayout.minimumSize() , unless the widget already has a minimum size. |
| QLayout.SetFixedSize | The main widget's size is set to PySide.QtGui.QLayoutItem.sizeHint() ; it cannot be resized at all. |
| QLayout.SetMinimumSize | The main widget's minimum size is set to PySide.QtGui.QLayout.minimumSize() ; it cannot be smaller. |
| QLayout.SetMaximumSize | The main widget's maximum size is set to PySide.QtGui.QLayout.maximumSize() ; it cannot be larger. |
| QLayout.SetMinAndMaxSize | The main widget's minimum size is set to PySide.QtGui.QLayout.minimumSize() and its maximum size is set to PySide.QtGui.QLayout.maximumSize() . |
| QLayout.SetNoConstraint | Widget 不受约束。 |
| 返回类型: | PySide.QtCore.bool |
|---|
重做布局为 PySide.QtGui.QLayout.parentWidget() 若有必要。
You should generally not need to call this because it is automatically called at the most appropriate times. It returns true if the layout was redone.
| 参数: | item – PySide.QtGui.QLayoutItem |
|---|
| 参数: | l – PySide.QtGui.QLayout |
|---|
此函数被调用从 addLayout() or insertLayout() functions in subclasses to add layout l as a sub-layout.
The only scenario in which you need to call it directly is if you implement a custom layout that supports nested layouts.
| 参数: | w – PySide.QtGui.QWidget |
|---|
此函数被调用从 addWidget() functions in subclasses to add w as a managed widget of a layout.
若 w is already managed by a layout, this function will give a warning and remove w from that layout. This function must therefore be called before adding w to the layout's data structure.
| 参数: | arg__1 – PySide.QtGui.QLayoutItem |
|---|
Implemented in subclasses to add an item . How it is added is specific to each subclass.
This function is not usually called in application code. To add a widget to a layout, use the PySide.QtGui.QLayout.addWidget() function; to add a child layout, use the addLayout() function provided by the relevant PySide.QtGui.QLayout 子类。
注意
The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
| 参数: | w – PySide.QtGui.QWidget |
|---|
添加 Widget w to this layout in a manner specific to the layout. This function uses PySide.QtGui.QLayout.addItem() .
| 参数: | layout – PySide.QtGui.QLayout |
|---|---|
| 返回类型: | PySide.QtCore.bool |
| 参数: | arg__1 – PySide.QtCore.QRect |
|---|---|
| 返回类型: | PySide.QtCore.QRect |
Returns the rectangle that should be covered when the geometry of this layout is set to r , provided that this layout supports PySide.QtGui.QLayout.setAlignment() .
The result is derived from PySide.QtGui.QLayoutItem.sizeHint() and expanding(). It is never larger than r .
| 参数: | |
|---|---|
| 返回类型: |
Returns a size that satisfies all size constraints on widget ,包括 PySide.QtGui.QLayoutItem.heightForWidth() and that is as close as possible to size .
| 返回类型: | PySide.QtCore.QMargins |
|---|
返回围绕布局所使用的边距。
默认情况下, PySide.QtGui.QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
| 返回类型: | PySide.QtCore.QRect |
|---|
返回布局的 PySide.QtGui.QLayout.geometry() rectangle, but taking into account the contents margins.
| 返回类型: | PySide.QtCore.int |
|---|
Must be implemented in subclasses to return the number of items in the layout.
Extracts the left, top, right, and bottom margins used around the layout, and assigns them to *``left`` , *``top`` , *``right`` , and *``bottom`` (unless they are null pointers).
默认情况下, PySide.QtGui.QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
另请参阅
PySide.QtGui.QLayout.setContentsMargins() QStyle.pixelMetric() PM_LayoutLeftMargin PM_LayoutTopMargin PM_LayoutRightMargin PM_LayoutBottomMargin
| 参数: | arg__1 – PySide.QtGui.QWidget |
|---|---|
| 返回类型: | PySide.QtCore.int |
搜索小部件 widget 在此布局 (不包括子级布局)。
Returns the index of widget , or -1 if widget 找不到。
默认实现遍历所有项,使用 PySide.QtGui.QLayout.itemAt()
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the layout is enabled; otherwise returns false.
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QLayoutItem |
Must be implemented in subclasses to return the layout item at index . If there is no such item, the function must return 0. Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered.
This function can be used to iterate over a layout. The following code will draw a rectangle for each layout item in the layout structure of the widget.
def paintLayout(self, painter, item):
layout = item.layout()
if layout:
for layout_item in layout:
self.paintLayout(painter, layout_item)
painter.drawRect(item.geometry())
def paintEvent(self, event):
painter = QPainter(self)
if self.layout():
self.paintLayout(painter, self.layout())
| 返回类型: | PySide.QtGui.QWidget |
|---|
Returns the menu bar set for this layout, or 0 if no menu bar is set.
| 返回类型: | PySide.QtGui.QWidget |
|---|
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget.
若布局是子布局,此函数返回父级布局的父级 Widget。
另请参阅
PySide.QtCore.QObject.parent()
| 参数: | arg__1 – PySide.QtGui.QLayoutItem |
|---|
移除布局项 item 从布局。删除项是调用者的责任。
预告: item 可以是布局 (由于 PySide.QtGui.QLayout 继承 PySide.QtGui.QLayoutItem ).
| 参数: | w – PySide.QtGui.QWidget |
|---|
移除 Widget widget from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout.
注意
The ownership of widget remains the same as when it was added.
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: | margins – PySide.QtCore.QMargins |
|---|
设置 margins 以围绕布局使用。
默认情况下, PySide.QtGui.QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
| 参数: |
|
|---|
设置 left , top , right ,和 bottom margins to use around the layout.
默认情况下, PySide.QtGui.QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
另请参阅
PySide.QtGui.QLayout.contentsMargins() PySide.QtGui.QLayout.getContentsMargins() QStyle.pixelMetric() PM_LayoutLeftMargin PM_LayoutTopMargin PM_LayoutRightMargin PM_LayoutBottomMargin
| 参数: | arg__1 – PySide.QtCore.bool |
|---|
启用此布局,若 enable 为 true,否则禁用它。
启用的布局会根据变化动态调整;禁用的布局就好像它不存在一样。
默认情况下,所有布局是启用的。
| 参数: | w – PySide.QtGui.QWidget |
|---|
Tells the geometry manager to place the menu bar widget at the top of PySide.QtGui.QLayout.parentWidget() , outside QWidget.contentsMargins() . All child widgets are placed below the bottom edge of the menu bar.
| 参数: | arg__1 – PySide.QtGui.QLayout.SizeConstraint |
|---|
This property holds the resize mode of the layout.
默认模式为 SetDefaultConstraint .
| 参数: | arg__1 – PySide.QtCore.int |
|---|
This property holds the spacing between widgets inside the layout.
If no value is explicitly set, the layout's spacing is inherited from the parent layout, or from the style settings for the parent widget.
For PySide.QtGui.QGridLayout and PySide.QtGui.QFormLayout , it is possible to set different horizontal and vertical spacings using PySide.QtGui.QGridLayout.setHorizontalSpacing() and PySide.QtGui.QGridLayout.setVerticalSpacing() . In that case, PySide.QtGui.QLayout.spacing() returns -1.
| 返回类型: | PySide.QtGui.QLayout.SizeConstraint |
|---|
This property holds the resize mode of the layout.
默认模式为 SetDefaultConstraint .
| 返回类型: | PySide.QtCore.int |
|---|
This property holds the spacing between widgets inside the layout.
If no value is explicitly set, the layout's spacing is inherited from the parent layout, or from the style settings for the parent widget.
For PySide.QtGui.QGridLayout and PySide.QtGui.QFormLayout , it is possible to set different horizontal and vertical spacings using PySide.QtGui.QGridLayout.setHorizontalSpacing() and PySide.QtGui.QGridLayout.setVerticalSpacing() . In that case, PySide.QtGui.QLayout.spacing() returns -1.
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QLayoutItem |
必须在子类中实现以移除布局项,在 index 从布局,并返回项。若没有这样的项,函数必须什么都不做,并返回 0。项从 0 起被连续编号。若项被移除,其它项将被重新编号。
下列代码片段展示从布局,安全移除所有项的办法:
child = layout.takeAt(0)
while child:
...
del child
| 参数: | w – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.int |
Also takes contentsMargins and menu bar into account.
| 返回类型: | PySide.QtCore.QSize |
|---|
Also takes contentsMargins and menu bar into account.
| 返回类型: | PySide.QtCore.QSize |
|---|
Also takes contentsMargins and menu bar into account.
| 返回类型: | PySide.QtCore.QSize |
|---|
Also takes contentsMargins and menu bar into account.
更新布局为 PySide.QtGui.QLayout.parentWidget() .
通常,不需要调用此,因为它会被自动调用 (在最合适时间)。
另请参阅
PySide.QtGui.QLayout.activate() PySide.QtGui.QLayout.invalidate()
| 参数: | arg__1 – PySide.QtCore.QEvent |
|---|
Performs child widget layout when the parent widget is resized. Also handles removal of widgets. e is the event