Skip to content

PythonQt.QtGui.QGraphicsGridLayout

QGraphicsGridLayout

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

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 calling addItem(), and finally assign the layout to a widget by calling QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes the dimensions of the grid as you add items.

QGraphicsScene scene;
QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);

QGraphicsGridLayout *layout = new QGraphicsGridLayout;
layout->addItem(textEdit, 0, 0);
layout->addItem(pushButton, 0, 1);

QGraphicsWidget *form = new 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 of QGraphicsLayoutItem::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

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 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.

Source: https://doc.qt.io/archives/qt-5.15/qgraphicsgridlayout.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
activate function (self) -> Any (shared captured text)
addChildLayoutItem function (self, layoutItem: Any) -> Any (shared captured text)
addItem function (self, item: Any, row: int, column: int, rowSpan: Any, columnSpan: Any, alignment: Any) -> None X.addItem(item, row, column, rowSpan, columnSpan, alignment)
alignment function (self, item: Any) -> Any Returns the alignment for item.
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
columnAlignment function (self, column: int) -> Any Returns the alignment for column.
columnCount function (self) -> int X.columnCount() -> int
columnMaximumWidth function (self, column: int) -> float X.columnMaximumWidth(column) -> float
columnMinimumWidth function (self, column: int) -> float X.columnMinimumWidth(column) -> float
columnPreferredWidth function (self, column: int) -> float X.columnPreferredWidth(column) -> float
columnSpacing function (self, column: int) -> float X.columnSpacing(column) -> float
columnStretchFactor function (self, column: int) -> int X.columnStretchFactor(column) -> int
contentsRect function (self) -> Any X.contentsRect() -> PythonQt.QtCore.QRectF (shared captured text)
count function (self) -> int X.count() -> int
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
effectiveSizeHint function (self, which: Any, constraint: Any) -> Any X.effectiveSizeHint(which, constraint) -> PythonQt.QtCore.QSizeF (shared captured text)
geometry function (self) -> Any X.geometry() -> PythonQt.QtCore.QRectF (shared captured text)
getContentsMargins function (self, left: Any, top: Any, right: Any, bottom: Any) -> Any X.getContentsMargins(left, top, right, bottom) (shared captured text)
graphicsItem function (self) -> Any X.graphicsItem() -> PythonQt.QtGui.QGraphicsItem (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
horizontalSpacing function (self) -> float X.horizontalSpacing() -> float
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
instantInvalidatePropagation function (self) -> bool X.instantInvalidatePropagation() -> bool (shared captured text)
invalidate function (self) -> None Reimplements: [QGraphicsLayout::invalidate](https://doc.qt.io/archives/qt-5.15/qgraphicslayout.html#invalidate)().
isActivated function (self) -> bool X.isActivated() -> bool (shared captured text)
isLayout function (self) -> bool X.isLayout() -> bool (shared captured text)
itemAt function (self, index: Any) -> Any X.itemAt(index) -> PythonQt.QtGui.QGraphicsLayoutItem
maximumHeight function (self) -> float X.maximumHeight() -> float (shared captured text)
maximumSize function (self) -> Any X.maximumSize() -> PythonQt.QtCore.QSizeF (shared captured text)
maximumWidth function (self) -> float X.maximumWidth() -> float (shared captured text)
minimumHeight function (self) -> float X.minimumHeight() -> float (shared captured text)
minimumSize function (self) -> Any X.minimumSize() -> PythonQt.QtCore.QSizeF (shared captured text)
minimumWidth function (self) -> float X.minimumWidth() -> float (shared captured text)
ownedByLayout function (self) -> bool X.ownedByLayout() -> bool (shared captured text)
parentLayoutItem function (self) -> Any X.parentLayoutItem() -> PythonQt.QtGui.QGraphicsLayoutItem (shared captured text)
preferredHeight function (self) -> float X.preferredHeight() -> float (shared captured text)
preferredSize function (self) -> Any X.preferredSize() -> PythonQt.QtCore.QSizeF (shared captured text)
preferredWidth function (self) -> float X.preferredWidth() -> float (shared captured text)
removeAt function (self, index: int) -> None Reimplements: [QGraphicsLayout::removeAt](https://doc.qt.io/archives/qt-5.15/qgraphicslayout.html#removeAt)(int index).
removeItem function (self, item: Any) -> None Removes the layout item item without destroying it.
rowAlignment function (self, row: int) -> Any Returns the alignment of row.
rowCount function (self) -> int X.rowCount() -> int
rowMaximumHeight function (self, row: int) -> float X.rowMaximumHeight(row) -> float
rowMinimumHeight function (self, row: int) -> float X.rowMinimumHeight(row) -> float
rowPreferredHeight function (self, row: int) -> float X.rowPreferredHeight(row) -> float
rowSpacing function (self, row: int) -> float X.rowSpacing(row) -> float
rowStretchFactor function (self, row: int) -> int X.rowStretchFactor(row) -> int
setAlignment function (self, item: Any, alignment: Any) -> None X.setAlignment(item, alignment)
setColumnAlignment function (self, column: int, alignment: Any) -> None X.setColumnAlignment(column, alignment)
setColumnFixedWidth function (self, column: int, width: float) -> None X.setColumnFixedWidth(column, width)
setColumnMaximumWidth function (self, column: int, width: float) -> None X.setColumnMaximumWidth(column, width)
setColumnMinimumWidth function (self, column: int, width: float) -> None X.setColumnMinimumWidth(column, width)
setColumnPreferredWidth function (self, column: int, width: float) -> None X.setColumnPreferredWidth(column, width)
setColumnSpacing function (self, column: int, spacing: float) -> None X.setColumnSpacing(column, spacing)
setColumnStretchFactor function (self, column: int, stretch: int) -> None X.setColumnStretchFactor(column, stretch)
setContentsMargins function (self, left: Any, top: Any, right: Any, bottom: Any) -> Any X.setContentsMargins(left, top, right, bottom) (shared captured text)
setGeometry function (self, rect: Any) -> None Reimplements: [QGraphicsLayoutItem::setGeometry](https://doc.qt.io/archives/qt-5.15/qgraphicslayoutitem.html#setGeometry)(const QRectF \&rect).
setGraphicsItem function (self, item: Any) -> Any (shared captured text)
setHorizontalSpacing function (self, spacing: float) -> None Sets the default horizontal spacing for the grid layout to spacing.
setInstantInvalidatePropagation function (self, enable: Any) -> Any (shared captured text)
setMaximumHeight function (self, height: Any) -> Any (shared captured text)
setMaximumSize function (self, w: Any, h: Any) -> Any X.setMaximumSize(w, h) (shared captured text)
setMaximumWidth function (self, width: Any) -> Any (shared captured text)
setMinimumHeight function (self, height: Any) -> Any (shared captured text)
setMinimumSize function (self, w: Any, h: Any) -> Any X.setMinimumSize(w, h) (shared captured text)
setMinimumWidth function (self, width: Any) -> Any (shared captured text)
setOwnedByLayout function (self, ownedByLayout: Any) -> Any (shared captured text)
setParentLayoutItem function (self, parent: Any) -> Any (shared captured text)
setPreferredHeight function (self, height: Any) -> Any (shared captured text)
setPreferredSize function (self, w: Any, h: Any) -> Any X.setPreferredSize(w, h) (shared captured text)
setPreferredWidth function (self, width: Any) -> Any (shared captured text)
setRowAlignment function (self, row: int, alignment: Any) -> None X.setRowAlignment(row, alignment)
setRowFixedHeight function (self, row: int, height: float) -> None X.setRowFixedHeight(row, height)
setRowMaximumHeight function (self, row: int, height: float) -> None X.setRowMaximumHeight(row, height)
setRowMinimumHeight function (self, row: int, height: float) -> None X.setRowMinimumHeight(row, height)
setRowPreferredHeight function (self, row: int, height: float) -> None X.setRowPreferredHeight(row, height)
setRowSpacing function (self, row: int, spacing: float) -> None X.setRowSpacing(row, spacing)
setRowStretchFactor function (self, row: int, stretch: int) -> None X.setRowStretchFactor(row, stretch)
setSizePolicy function (self, hPolicy: Any, vPolicy: Any, controlType: Any) -> Any X.setSizePolicy(hPolicy, vPolicy, controlType) (shared captured text)
setSpacing function (self, spacing: float) -> None Sets the grid layout's default spacing, both vertical and horizontal, to spacing.
setVerticalSpacing function (self, spacing: float) -> None Sets the default vertical spacing for the grid layout to spacing.
sizeHint function (self, which: Any, constraint: Any) -> Any X.sizeHint(which, constraint) -> PythonQt.QtCore.QSizeF
sizePolicy function (self) -> Any X.sizePolicy() -> PythonQt.QtGui.QSizePolicy (shared captured text)
updateGeometry function (self) -> Any (shared captured text)
verticalSpacing function (self) -> float X.verticalSpacing() -> float
widgetEvent function (self, e: Any) -> Any (shared captured text)