QGraphicsGridLayout

Inheritance diagram of QGraphicsGridLayout

Synopsis

Functions

Detailed Description

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.

Size Hints and Size Policies in QGraphicsGridLayout

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.

class PySide.QtGui.QGraphicsGridLayout([parent=None])
Parameters:parentPySide.QtGui.QGraphicsLayoutItem

Constructs a PySide.QtGui.QGraphicsGridLayout instance. parent is passed to PySide.QtGui.QGraphicsLayout ‘s constructor.

PySide.QtGui.QGraphicsGridLayout.addItem(item, row, column, rowSpan, columnSpan[, alignment=0])
Parameters:
  • itemPySide.QtGui.QGraphicsLayoutItem
  • rowPySide.QtCore.int
  • columnPySide.QtCore.int
  • rowSpanPySide.QtCore.int
  • columnSpanPySide.QtCore.int
  • alignmentPySide.QtCore.Qt.Alignment
PySide.QtGui.QGraphicsGridLayout.addItem(item, row, column[, alignment=0])
Parameters:
PySide.QtGui.QGraphicsGridLayout.alignment(item)
Parameters:itemPySide.QtGui.QGraphicsLayoutItem
Return type:PySide.QtCore.Qt.Alignment

Returns the alignment for item .

PySide.QtGui.QGraphicsGridLayout.columnAlignment(column)
Parameters:columnPySide.QtCore.int
Return type:PySide.QtCore.Qt.Alignment

Returns the alignment for column .

PySide.QtGui.QGraphicsGridLayout.columnCount()
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).

PySide.QtGui.QGraphicsGridLayout.columnMaximumWidth(column)
Parameters:columnPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the maximum width for column .

PySide.QtGui.QGraphicsGridLayout.columnMinimumWidth(column)
Parameters:columnPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the minimum width for column .

PySide.QtGui.QGraphicsGridLayout.columnPreferredWidth(column)
Parameters:columnPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the preferred width for column .

PySide.QtGui.QGraphicsGridLayout.columnSpacing(column)
Parameters:columnPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the column spacing for column .

PySide.QtGui.QGraphicsGridLayout.columnStretchFactor(column)
Parameters:columnPySide.QtCore.int
Return type:PySide.QtCore.int

Returns the stretch factor for column .

PySide.QtGui.QGraphicsGridLayout.horizontalSpacing()
Return type:PySide.QtCore.qreal

Returns the default horizontal spacing for the grid layout.

PySide.QtGui.QGraphicsGridLayout.itemAt(row, column)
Parameters:
  • rowPySide.QtCore.int
  • columnPySide.QtCore.int
Return type:

PySide.QtGui.QGraphicsLayoutItem

Returns a pointer to the layout item at (row , column ).

PySide.QtGui.QGraphicsGridLayout.rowAlignment(row)
Parameters:rowPySide.QtCore.int
Return type:PySide.QtCore.Qt.Alignment

Returns the alignment of row .

PySide.QtGui.QGraphicsGridLayout.rowCount()
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).

PySide.QtGui.QGraphicsGridLayout.rowMaximumHeight(row)
Parameters:rowPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the maximum height for row, row .

PySide.QtGui.QGraphicsGridLayout.rowMinimumHeight(row)
Parameters:rowPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the minimum height for row, row .

PySide.QtGui.QGraphicsGridLayout.rowPreferredHeight(row)
Parameters:rowPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the preferred height for row, row .

PySide.QtGui.QGraphicsGridLayout.rowSpacing(row)
Parameters:rowPySide.QtCore.int
Return type:PySide.QtCore.qreal

Returns the row spacing for row .

PySide.QtGui.QGraphicsGridLayout.rowStretchFactor(row)
Parameters:rowPySide.QtCore.int
Return type:PySide.QtCore.int

Returns the stretch factor for row .

PySide.QtGui.QGraphicsGridLayout.setAlignment(item, alignment)
Parameters:
PySide.QtGui.QGraphicsGridLayout.setColumnAlignment(column, alignment)
Parameters:
  • columnPySide.QtCore.int
  • alignmentPySide.QtCore.Qt.Alignment
PySide.QtGui.QGraphicsGridLayout.setColumnFixedWidth(column, width)
Parameters:
  • columnPySide.QtCore.int
  • widthPySide.QtCore.qreal

Sets the fixed width of column to width .

PySide.QtGui.QGraphicsGridLayout.setColumnMaximumWidth(column, width)
Parameters:
  • columnPySide.QtCore.int
  • widthPySide.QtCore.qreal

Sets the maximum width of column to width .

PySide.QtGui.QGraphicsGridLayout.setColumnMinimumWidth(column, width)
Parameters:
  • columnPySide.QtCore.int
  • widthPySide.QtCore.qreal

Sets the minimum width for column to width .

PySide.QtGui.QGraphicsGridLayout.setColumnPreferredWidth(column, width)
Parameters:
  • columnPySide.QtCore.int
  • widthPySide.QtCore.qreal

Sets the preferred width for column to width .

PySide.QtGui.QGraphicsGridLayout.setColumnSpacing(column, spacing)
Parameters:
  • columnPySide.QtCore.int
  • spacingPySide.QtCore.qreal

Sets the spacing for column to spacing .

PySide.QtGui.QGraphicsGridLayout.setColumnStretchFactor(column, stretch)
Parameters:
  • columnPySide.QtCore.int
  • stretchPySide.QtCore.int

Sets the stretch factor for column to stretch .

PySide.QtGui.QGraphicsGridLayout.setHorizontalSpacing(spacing)
Parameters:spacingPySide.QtCore.qreal

Sets the default horizontal spacing for the grid layout to spacing .

PySide.QtGui.QGraphicsGridLayout.setRowAlignment(row, alignment)
Parameters:
  • rowPySide.QtCore.int
  • alignmentPySide.QtCore.Qt.Alignment
PySide.QtGui.QGraphicsGridLayout.setRowFixedHeight(row, height)
Parameters:
  • rowPySide.QtCore.int
  • heightPySide.QtCore.qreal

Sets the fixed height for row, row , to height .

PySide.QtGui.QGraphicsGridLayout.setRowMaximumHeight(row, height)
Parameters:
  • rowPySide.QtCore.int
  • heightPySide.QtCore.qreal

Sets the maximum height for row, row , to height .

PySide.QtGui.QGraphicsGridLayout.setRowMinimumHeight(row, height)
Parameters:
  • rowPySide.QtCore.int
  • heightPySide.QtCore.qreal

Sets the minimum height for row, row , to height .

PySide.QtGui.QGraphicsGridLayout.setRowPreferredHeight(row, height)
Parameters:
  • rowPySide.QtCore.int
  • heightPySide.QtCore.qreal

Sets the preferred height for row, row , to height .

PySide.QtGui.QGraphicsGridLayout.setRowSpacing(row, spacing)
Parameters:
  • rowPySide.QtCore.int
  • spacingPySide.QtCore.qreal

Sets the spacing for row to spacing .

PySide.QtGui.QGraphicsGridLayout.setRowStretchFactor(row, stretch)
Parameters:
  • rowPySide.QtCore.int
  • stretchPySide.QtCore.int

Sets the stretch factor for row to stretch .

PySide.QtGui.QGraphicsGridLayout.setSpacing(spacing)
Parameters:spacingPySide.QtCore.qreal

Sets the grid layout’s default spacing, both vertical and horizontal, to spacing .

PySide.QtGui.QGraphicsGridLayout.setVerticalSpacing(spacing)
Parameters:spacingPySide.QtCore.qreal

Sets the default vertical spacing for the grid layout to spacing .

PySide.QtGui.QGraphicsGridLayout.verticalSpacing()
Return type:PySide.QtCore.qreal

Returns the default vertical spacing for the grid layout.