PySide6.QtWidgets.QGraphicsGridLayout¶
- class QGraphicsGridLayout¶
- The - QGraphicsGridLayoutclass provides a grid layout for managing widgets in Graphics View. More…- Synopsis¶- Methods¶- def - __init__()
- def - addItem()
- def - alignment()
- def - columnCount()
- def - columnSpacing()
- def - itemAt()
- def - removeItem()
- def - rowAlignment()
- def - rowCount()
- def - rowSpacing()
- def - setAlignment()
- def - setRowSpacing()
- def - setSpacing()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - The most common way to use - QGraphicsGridLayoutis to construct an object on the heap, passing a parent widget to the constructor, then add widgets and layouts by calling- addItem().- QGraphicsGridLayoutautomatically computes the dimensions of the grid as you add items.- scene = QGraphicsScene() textEdit = scene.addWidget(QTextEdit()) pushButton = scene.addWidget(QPushButton()) form = QGraphicsWidget() scene.addItem(form) layout = QGraphicsGridLayout(form) layout.addItem(textEdit, 0, 0) layout.addItem(pushButton, 0, 1) - Alternatively, if you do not pass a parent widget to the layout’s constructor, you will need to call - setLayout()to set this layout as the top-level layout for that widget, the widget will take ownership of the layout.- The layout takes ownership of the items. In some cases when the layout item also inherits from - QGraphicsItem(such as- QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of- setOwnedByLayout()how to handle this. You can access each item in the layout by calling- count()and- itemAt(). Calling- removeAt()will remove an item from the layout, without destroying it.- Size Hints and Size Policies in QGraphicsGridLayout¶- QGraphicsGridLayoutrespects 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- setAlignment(), and check the alignment for any item by calling- alignment(). You can also set the alignment for an entire row or column by calling- setRowAlignment()and- setColumnAlignment()respectively. By default, items are aligned to the top left.- See also - __init__([parent=None])¶
- Parameters:
- parent – - QGraphicsLayoutItem
 
 - Constructs a - QGraphicsGridLayoutinstance.- parentis passed to- QGraphicsLayout‘s constructor.- addItem(item, row, column[, alignment=Qt.Alignment()])¶
- Parameters:
- item – - QGraphicsLayoutItem
- row – int 
- column – int 
- alignment – Combination of - AlignmentFlag
 
 
 - Adds - itemto the grid on- rowand- column. You can specify an optional- alignmentfor- item.- addItem(item, row, column, rowSpan, columnSpan[, alignment=Qt.Alignment()])
- Parameters:
- item – - QGraphicsLayoutItem
- row – int 
- column – int 
- rowSpan – int 
- columnSpan – int 
- alignment – Combination of - AlignmentFlag
 
 
 - Adds - itemto the grid on- rowand- column. You can specify a- rowSpanand- columnSpanand an optional- alignment.- alignment(item)¶
- Parameters:
- item – - QGraphicsLayoutItem
- Return type:
- Combination of - AlignmentFlag
 
 - Returns the alignment for - item.- See also - columnAlignment(column)¶
- Parameters:
- column – int 
- Return type:
- Combination of - AlignmentFlag
 
 - Returns the alignment for - column.- See also - columnCount()¶
- Return type:
- 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). - columnMaximumWidth(column)¶
- Parameters:
- column – int 
- Return type:
- float 
 
 - Returns the maximum width for - column.- See also - columnMinimumWidth(column)¶
- Parameters:
- column – int 
- Return type:
- float 
 
 - Returns the minimum width for - column.- See also - columnPreferredWidth(column)¶
- Parameters:
- column – int 
- Return type:
- float 
 
 - Returns the preferred width for - column.- See also - columnSpacing(column)¶
- Parameters:
- column – int 
- Return type:
- float 
 
 - Returns the column spacing for - column.- See also - columnStretchFactor(column)¶
- Parameters:
- column – int 
- Return type:
- int 
 
 - Returns the stretch factor for - column.- See also - horizontalSpacing()¶
- Return type:
- float 
 
 - Returns the default horizontal spacing for the grid layout. - See also - itemAt(row, column)¶
- Parameters:
- row – int 
- column – int 
 
- Return type:
 
 - Returns a pointer to the layout item at ( - row,- column).- removeItem(item)¶
- Parameters:
- item – - QGraphicsLayoutItem
 
 - Removes the layout item - itemwithout destroying it. Ownership of the item is transferred to the caller.- See also - rowAlignment(row)¶
- Parameters:
- row – int 
- Return type:
- Combination of - AlignmentFlag
 
 - Returns the alignment of - row.- See also - rowCount()¶
- Return type:
- 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). - rowMaximumHeight(row)¶
- Parameters:
- row – int 
- Return type:
- float 
 
 - Returns the maximum height for row, - row.- See also - rowMinimumHeight(row)¶
- Parameters:
- row – int 
- Return type:
- float 
 
 - Returns the minimum height for row, - row.- See also - rowPreferredHeight(row)¶
- Parameters:
- row – int 
- Return type:
- float 
 
 - Returns the preferred height for row, - row.- See also - rowSpacing(row)¶
- Parameters:
- row – int 
- Return type:
- float 
 
 - Returns the row spacing for - row.- See also - rowStretchFactor(row)¶
- Parameters:
- row – int 
- Return type:
- int 
 
 - Returns the stretch factor for - row.- See also - setAlignment(item, alignment)¶
- Parameters:
- item – - QGraphicsLayoutItem
- alignment – Combination of - AlignmentFlag
 
 
 - Sets the alignment for - itemto- alignment.- See also - setColumnAlignment(column, alignment)¶
- Parameters:
- column – int 
- alignment – Combination of - AlignmentFlag
 
 
 - Sets the alignment for - columnto- alignment.- See also - setColumnFixedWidth(column, width)¶
- Parameters:
- column – int 
- width – float 
 
 
 - Sets the fixed width of - columnto- width.- setColumnMaximumWidth(column, width)¶
- Parameters:
- column – int 
- width – float 
 
 
 - Sets the maximum width of - columnto- width.- See also - setColumnMinimumWidth(column, width)¶
- Parameters:
- column – int 
- width – float 
 
 
 - Sets the minimum width for - columnto- width.- See also - setColumnPreferredWidth(column, width)¶
- Parameters:
- column – int 
- width – float 
 
 
 - Sets the preferred width for - columnto- width.- See also - setColumnSpacing(column, spacing)¶
- Parameters:
- column – int 
- spacing – float 
 
 
 - Sets the spacing for - columnto- spacing.- See also - setColumnStretchFactor(column, stretch)¶
- Parameters:
- column – int 
- stretch – int 
 
 
 - Sets the stretch factor for - columnto- stretch.- See also - setHorizontalSpacing(spacing)¶
- Parameters:
- spacing – float 
 
 - Sets the default horizontal spacing for the grid layout to - spacing.- See also - setRowAlignment(row, alignment)¶
- Parameters:
- row – int 
- alignment – Combination of - AlignmentFlag
 
 
 - Sets the alignment of - rowto- alignment.- See also - setRowFixedHeight(row, height)¶
- Parameters:
- row – int 
- height – float 
 
 
 - Sets the fixed height for row, - row, to- height.- setRowMaximumHeight(row, height)¶
- Parameters:
- row – int 
- height – float 
 
 
 - Sets the maximum height for row, - row, to- height.- See also - setRowMinimumHeight(row, height)¶
- Parameters:
- row – int 
- height – float 
 
 
 - Sets the minimum height for row, - row, to- height.- See also - setRowPreferredHeight(row, height)¶
- Parameters:
- row – int 
- height – float 
 
 
 - Sets the preferred height for row, - row, to- height.- See also - setRowSpacing(row, spacing)¶
- Parameters:
- row – int 
- spacing – float 
 
 
 - Sets the spacing for - rowto- spacing.- See also - setRowStretchFactor(row, stretch)¶
- Parameters:
- row – int 
- stretch – int 
 
 
 - Sets the stretch factor for - rowto- stretch.- See also - setSpacing(spacing)¶
- Parameters:
- spacing – float 
 
 - Sets the grid layout’s default spacing, both vertical and horizontal, to - spacing.- See also - setVerticalSpacing(spacing)¶
- Parameters:
- spacing – float 
 
 - Sets the default vertical spacing for the grid layout to - spacing.- See also - verticalSpacing()¶
- Return type:
- float 
 
 - Returns the default vertical spacing for the grid layout. - See also