The PySide.QtGui.QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View.
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 (such as 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() . Calling 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.
Parameters: | parent – PySide.QtGui.QGraphicsLayoutItem |
---|
Constructs a PySide.QtGui.QGraphicsGridLayout instance. parent is passed to PySide.QtGui.QGraphicsLayout ‘s constructor.
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: | item – PySide.QtGui.QGraphicsLayoutItem |
---|---|
Return type: | PySide.QtCore.Qt.Alignment |
Returns the alignment for item .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.Qt.Alignment |
Returns the alignment for column .
Return type: | 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).
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the maximum width for column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the minimum width for column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the preferred width for column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the column spacing for column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.int |
Returns the stretch factor for column .
Return type: | PySide.QtCore.qreal |
---|
Returns the default horizontal spacing for the grid layout.
Parameters: |
|
---|---|
Return type: |
Returns a pointer to the layout item at (row , column ).
Parameters: | item – PySide.QtGui.QGraphicsLayoutItem |
---|
Removes the layout item item without destroying it. Ownership of the item is transferred to the caller.
Parameters: | row – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.Qt.Alignment |
Returns the alignment of row .
Return type: | 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).
Parameters: | row – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the maximum height for row, row .
Parameters: | row – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the minimum height for row, row .
Parameters: | row – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the preferred height for row, row .
Parameters: | row – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.qreal |
Returns the row spacing for row .
Parameters: | row – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.int |
Returns the stretch factor for row .
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Sets the fixed width of column to width .
Parameters: |
|
---|
Sets the maximum width of column to width .
Parameters: |
|
---|
Sets the minimum width for column to width .
Parameters: |
|
---|
Sets the preferred width for column to width .
Parameters: |
|
---|
Sets the spacing for column to spacing .
Parameters: |
|
---|
Sets the stretch factor for column to stretch .
Parameters: | spacing – PySide.QtCore.qreal |
---|
Sets the default horizontal spacing for the grid layout to spacing .
Parameters: |
|
---|
Parameters: |
|
---|
Sets the fixed height for row, row , to height .
Parameters: |
|
---|
Sets the maximum height for row, row , to height .
Parameters: |
|
---|
Sets the minimum height for row, row , to height .
Parameters: |
|
---|
Sets the preferred height for row, row , to height .
Parameters: |
|
---|
Sets the spacing for row to spacing .
Parameters: |
|
---|
Sets the stretch factor for row to stretch .
Parameters: | spacing – PySide.QtCore.qreal |
---|
Sets the grid layout’s default spacing, both vertical and horizontal, to spacing .
Parameters: | spacing – PySide.QtCore.qreal |
---|
Sets the default vertical spacing for the grid layout to spacing .
Return type: | PySide.QtCore.qreal |
---|
Returns the default vertical spacing for the grid layout.