PySide.QtGui.QGraphicsGridLayout 类提供在图形视图管理 Widget 的栅格。
The most common way to use PySide.QtGui.QGraphicsGridLayout is to construct an object on the heap with no parent, add widgets and layouts by calling PySide.QtGui.QGraphicsGridLayout.addItem() , and finally assign the layout to a widget by calling QGraphicsWidget.setLayout() . PySide.QtGui.QGraphicsGridLayout automatically computes the dimensions of the grid as you add items.
scene = QGraphicsScene()
textEdit = scene.addWidget(QTextEdit())
pushButton = scene.addWidget(QPushButton())
layout = QGraphicsGridLayout()
layout.addItem(textEdit, 0, 0)
layout.addItem(pushButton, 0, 1)
form = QGraphicsWidget()
form.setLayout(layout)
scene.addItem(form)
The layout takes ownership of the items. In some cases when the layout item also inherits from PySide.QtGui.QGraphicsItem (譬如 PySide.QtGui.QGraphicsWidget ) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem.setOwnedByLayout() how to handle this. You can access each item in the layout by calling PySide.QtGui.QGraphicsGridLayout.count() and PySide.QtGui.QGraphicsGridLayout.itemAt() 。调用 PySide.QtGui.QGraphicsGridLayout.removeAt() will remove an item from the layout, without destroying it.
PySide.QtGui.QGraphicsGridLayout respects each item's size hints and size policies, and when a cell in the grid has more space than the items can fill, each item is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling PySide.QtGui.QGraphicsGridLayout.setAlignment() , and check the alignment for any item by calling PySide.QtGui.QGraphicsGridLayout.alignment() . You can also set the alignment for an entire row or column by calling PySide.QtGui.QGraphicsGridLayout.setRowAlignment() and PySide.QtGui.QGraphicsGridLayout.setColumnAlignment() respectively. By default, items are aligned to the top left.
| 参数: | parent – PySide.QtGui.QGraphicsLayoutItem |
|---|
构造 PySide.QtGui.QGraphicsGridLayout 实例。 parent 会被传递给 PySide.QtGui.QGraphicsLayout ‘s constructor.
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: | item – PySide.QtGui.QGraphicsLayoutItem |
|---|---|
| 返回类型: | PySide.QtCore.Qt.Alignment |
返回对齐方式为 item .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.Qt.Alignment |
返回对齐方式为 column .
| 返回类型: | PySide.QtCore.int |
|---|
Returns the number of columns in the grid layout. This is always one more than the index of the last column that is occupied by a layout item (empty columns are counted except for those at the end).
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
返回最大宽度为 column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the minimum width for column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the preferred width for column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the column spacing for column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.int |
Returns the stretch factor for column .
| 返回类型: | PySide.QtCore.qreal |
|---|
Returns the default horizontal spacing for the grid layout.
| 参数: |
|
|---|---|
| 返回类型: |
Returns a pointer to the layout item at ( row , column ).
| 参数: | item – PySide.QtGui.QGraphicsLayoutItem |
|---|
移除布局项 item without destroying it. Ownership of the item is transferred to the caller.
| 参数: | row – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.Qt.Alignment |
Returns the alignment of row .
| 返回类型: | PySide.QtCore.int |
|---|
Returns the number of rows in the grid layout. This is always one more than the index of the last row that is occupied by a layout item (empty rows are counted except for those at the end).
| 参数: | row – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the maximum height for row, row .
| 参数: | row – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the minimum height for row, row .
| 参数: | row – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the preferred height for row, row .
| 参数: | row – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.qreal |
Returns the row spacing for row .
| 参数: | row – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.int |
Returns the stretch factor for row .
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
Sets the fixed width of column to width .
| 参数: |
|
|---|
Sets the maximum width of column to width .
| 参数: |
|
|---|
Sets the minimum width for column to width .
| 参数: |
|
|---|
Sets the preferred width for column to width .
| 参数: |
|
|---|
Sets the spacing for column to spacing .
| 参数: |
|
|---|
设置拉伸因子为 column to stretch .
| 参数: | spacing – PySide.QtCore.qreal |
|---|
Sets the default horizontal spacing for the grid layout to spacing .
| 参数: |
|
|---|
| 参数: |
|
|---|
Sets the fixed height for row, row ,到 height .
| 参数: |
|
|---|
Sets the maximum height for row, row ,到 height .
| 参数: |
|
|---|
Sets the minimum height for row, row ,到 height .
| 参数: |
|
|---|
Sets the preferred height for row, row ,到 height .
| 参数: |
|
|---|
Sets the spacing for row to spacing .
| 参数: |
|
|---|
设置拉伸因子为 row to stretch .
| 参数: | spacing – PySide.QtCore.qreal |
|---|
Sets the grid layout's default spacing, both vertical and horizontal, to spacing .
| 参数: | spacing – PySide.QtCore.qreal |
|---|
Sets the default vertical spacing for the grid layout to spacing .
| 返回类型: | PySide.QtCore.qreal |
|---|
Returns the default vertical spacing for the grid layout.