QGraphicsGridLayout¶
The
QGraphicsGridLayout
class provides a grid layout for managing widgets in Graphics View. More…
Synopsis¶
Functions¶
def
addItem
(item, row, column, rowSpan, columnSpan[, alignment=Qt.Alignment()])def
addItem
(item, row, column[, alignment=Qt.Alignment()])def
alignment
(item)def
columnAlignment
(column)def
columnCount
()def
columnMaximumWidth
(column)def
columnMinimumWidth
(column)def
columnPreferredWidth
(column)def
columnSpacing
(column)def
columnStretchFactor
(column)def
horizontalSpacing
()def
itemAt
(row, column)def
removeItem
(item)def
rowAlignment
(row)def
rowCount
()def
rowMaximumHeight
(row)def
rowMinimumHeight
(row)def
rowPreferredHeight
(row)def
rowSpacing
(row)def
rowStretchFactor
(row)def
setAlignment
(item, alignment)def
setColumnAlignment
(column, alignment)def
setColumnFixedWidth
(column, width)def
setColumnMaximumWidth
(column, width)def
setColumnMinimumWidth
(column, width)def
setColumnPreferredWidth
(column, width)def
setColumnSpacing
(column, spacing)def
setColumnStretchFactor
(column, stretch)def
setHorizontalSpacing
(spacing)def
setRowAlignment
(row, alignment)def
setRowFixedHeight
(row, height)def
setRowMaximumHeight
(row, height)def
setRowMinimumHeight
(row, height)def
setRowPreferredHeight
(row, height)def
setRowSpacing
(row, spacing)def
setRowStretchFactor
(row, stretch)def
setSpacing
(spacing)def
setVerticalSpacing
(spacing)def
verticalSpacing
()
Detailed Description¶
The most common way to use
QGraphicsGridLayout
is to construct an object on the heap with no parent, add widgets and layouts by callingaddItem()
, and finally assign the layout to a widget by callingsetLayout()
.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
QGraphicsItem
(such as QGraphicsWidget ) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation ofsetOwnedByLayout()
how to handle this. You can access each item in the layout by callingcount()
anditemAt()
. CallingremoveAt()
will remove an item from the layout, without destroying it.
Size Hints and Size Policies in QGraphicsGridLayout¶
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 callingsetAlignment()
, and check the alignment for any item by callingalignment()
. You can also set the alignment for an entire row or column by callingsetRowAlignment()
andsetColumnAlignment()
respectively. By default, items are aligned to the top left.See also
- class PySide2.QtWidgets.QGraphicsGridLayout([parent=None])¶
- param parent:
Constructs a
QGraphicsGridLayout
instance.parent
is passed to QGraphicsLayout ‘s constructor.
- PySide2.QtWidgets.QGraphicsGridLayout.addItem(item, row, column[, alignment=Qt.Alignment()])¶
- Parameters:
row – int
column – int
alignment –
Alignment
Adds
item
to the grid onrow
andcolumn
. You can specify an optionalalignment
foritem
.
- PySide2.QtWidgets.QGraphicsGridLayout.addItem(item, row, column, rowSpan, columnSpan[, alignment=Qt.Alignment()])
- Parameters:
row – int
column – int
rowSpan – int
columnSpan – int
alignment –
Alignment
Adds
item
to the grid onrow
andcolumn
. You can specify arowSpan
andcolumnSpan
and an optionalalignment
.
- PySide2.QtWidgets.QGraphicsGridLayout.alignment(item)¶
- Parameters:
- Return type:
Alignment
Returns the alignment for
item
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.columnAlignment(column)¶
- Parameters:
column – int
- Return type:
Alignment
Returns the alignment for
column
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.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).
- PySide2.QtWidgets.QGraphicsGridLayout.columnMaximumWidth(column)¶
- Parameters:
column – int
- Return type:
float
Returns the maximum width for
column
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.columnMinimumWidth(column)¶
- Parameters:
column – int
- Return type:
float
Returns the minimum width for
column
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.columnPreferredWidth(column)¶
- Parameters:
column – int
- Return type:
float
Returns the preferred width for
column
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.columnSpacing(column)¶
- Parameters:
column – int
- Return type:
float
Returns the column spacing for
column
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.columnStretchFactor(column)¶
- Parameters:
column – int
- Return type:
int
Returns the stretch factor for
column
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.horizontalSpacing()¶
- Return type:
float
Returns the default horizontal spacing for the grid layout.
See also
- PySide2.QtWidgets.QGraphicsGridLayout.itemAt(row, column)¶
- Parameters:
row – int
column – int
- Return type:
Returns a pointer to the layout item at (
row
,column
).
- PySide2.QtWidgets.QGraphicsGridLayout.removeItem(item)¶
- Parameters:
Removes the layout item
item
without destroying it. Ownership of the item is transferred to the caller.See also
- PySide2.QtWidgets.QGraphicsGridLayout.rowAlignment(row)¶
- Parameters:
row – int
- Return type:
Alignment
Returns the alignment of
row
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.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).
- PySide2.QtWidgets.QGraphicsGridLayout.rowMaximumHeight(row)¶
- Parameters:
row – int
- Return type:
float
Returns the maximum height for row,
row
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.rowMinimumHeight(row)¶
- Parameters:
row – int
- Return type:
float
Returns the minimum height for row,
row
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.rowPreferredHeight(row)¶
- Parameters:
row – int
- Return type:
float
Returns the preferred height for row,
row
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.rowSpacing(row)¶
- Parameters:
row – int
- Return type:
float
Returns the row spacing for
row
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.rowStretchFactor(row)¶
- Parameters:
row – int
- Return type:
int
Returns the stretch factor for
row
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setAlignment(item, alignment)¶
- Parameters:
alignment –
Alignment
Sets the alignment for
item
toalignment
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnAlignment(column, alignment)¶
- Parameters:
column – int
alignment –
Alignment
Sets the alignment for
column
toalignment
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnFixedWidth(column, width)¶
- Parameters:
column – int
width – float
Sets the fixed width of
column
towidth
.
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnMaximumWidth(column, width)¶
- Parameters:
column – int
width – float
Sets the maximum width of
column
towidth
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnMinimumWidth(column, width)¶
- Parameters:
column – int
width – float
Sets the minimum width for
column
towidth
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnPreferredWidth(column, width)¶
- Parameters:
column – int
width – float
Sets the preferred width for
column
towidth
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnSpacing(column, spacing)¶
- Parameters:
column – int
spacing – float
Sets the spacing for
column
tospacing
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setColumnStretchFactor(column, stretch)¶
- Parameters:
column – int
stretch – int
Sets the stretch factor for
column
tostretch
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setHorizontalSpacing(spacing)¶
- Parameters:
spacing – float
Sets the default horizontal spacing for the grid layout to
spacing
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setRowAlignment(row, alignment)¶
- Parameters:
row – int
alignment –
Alignment
Sets the alignment of
row
toalignment
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setRowFixedHeight(row, height)¶
- Parameters:
row – int
height – float
Sets the fixed height for row,
row
, toheight
.
- PySide2.QtWidgets.QGraphicsGridLayout.setRowMaximumHeight(row, height)¶
- Parameters:
row – int
height – float
Sets the maximum height for row,
row
, toheight
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setRowMinimumHeight(row, height)¶
- Parameters:
row – int
height – float
Sets the minimum height for row,
row
, toheight
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setRowPreferredHeight(row, height)¶
- Parameters:
row – int
height – float
Sets the preferred height for row,
row
, toheight
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setRowSpacing(row, spacing)¶
- Parameters:
row – int
spacing – float
Sets the spacing for
row
tospacing
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setRowStretchFactor(row, stretch)¶
- Parameters:
row – int
stretch – int
Sets the stretch factor for
row
tostretch
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setSpacing(spacing)¶
- Parameters:
spacing – float
Sets the grid layout’s default spacing, both vertical and horizontal, to
spacing
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.setVerticalSpacing(spacing)¶
- Parameters:
spacing – float
Sets the default vertical spacing for the grid layout to
spacing
.See also
- PySide2.QtWidgets.QGraphicsGridLayout.verticalSpacing()¶
- Return type:
float
Returns the default vertical spacing for the grid layout.
See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.