Skip to content

PythonQt.Qt.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) (shared captured text)
alignment function (self, item: Any) -> Any Returns the alignment for item. (shared captured text)
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. (shared captured text)
columnCount function (self) -> int X.columnCount() -> int (shared captured text)
columnMaximumWidth function (self, column: int) -> float X.columnMaximumWidth(column) -> float (shared captured text)
columnMinimumWidth function (self, column: int) -> float X.columnMinimumWidth(column) -> float (shared captured text)
columnPreferredWidth function (self, column: int) -> float X.columnPreferredWidth(column) -> float (shared captured text)
columnSpacing function (self, column: int) -> float X.columnSpacing(column) -> float (shared captured text)
columnStretchFactor function (self, column: int) -> int X.columnStretchFactor(column) -> int (shared captured text)
contentsRect function (self) -> Any X.contentsRect() -> PythonQt.QtCore.QRectF (shared captured text)
count function (self) -> int X.count() -> int (shared captured text)
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 (shared captured text)
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)(). (shared captured text)
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 (shared captured text)
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). (shared captured text)
removeItem function (self, item: Any) -> None Removes the layout item item without destroying it. (shared captured text)
rowAlignment function (self, row: int) -> Any Returns the alignment of row. (shared captured text)
rowCount function (self) -> int X.rowCount() -> int (shared captured text)
rowMaximumHeight function (self, row: int) -> float X.rowMaximumHeight(row) -> float (shared captured text)
rowMinimumHeight function (self, row: int) -> float X.rowMinimumHeight(row) -> float (shared captured text)
rowPreferredHeight function (self, row: int) -> float X.rowPreferredHeight(row) -> float (shared captured text)
rowSpacing function (self, row: int) -> float X.rowSpacing(row) -> float (shared captured text)
rowStretchFactor function (self, row: int) -> int X.rowStretchFactor(row) -> int (shared captured text)
setAlignment function (self, item: Any, alignment: Any) -> None X.setAlignment(item, alignment) (shared captured text)
setColumnAlignment function (self, column: int, alignment: Any) -> None X.setColumnAlignment(column, alignment) (shared captured text)
setColumnFixedWidth function (self, column: int, width: float) -> None X.setColumnFixedWidth(column, width) (shared captured text)
setColumnMaximumWidth function (self, column: int, width: float) -> None X.setColumnMaximumWidth(column, width) (shared captured text)
setColumnMinimumWidth function (self, column: int, width: float) -> None X.setColumnMinimumWidth(column, width) (shared captured text)
setColumnPreferredWidth function (self, column: int, width: float) -> None X.setColumnPreferredWidth(column, width) (shared captured text)
setColumnSpacing function (self, column: int, spacing: float) -> None X.setColumnSpacing(column, spacing) (shared captured text)
setColumnStretchFactor function (self, column: int, stretch: int) -> None X.setColumnStretchFactor(column, stretch) (shared captured text)
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). (shared captured text)
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. (shared captured text)
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) (shared captured text)
setRowFixedHeight function (self, row: int, height: float) -> None X.setRowFixedHeight(row, height) (shared captured text)
setRowMaximumHeight function (self, row: int, height: float) -> None X.setRowMaximumHeight(row, height) (shared captured text)
setRowMinimumHeight function (self, row: int, height: float) -> None X.setRowMinimumHeight(row, height) (shared captured text)
setRowPreferredHeight function (self, row: int, height: float) -> None X.setRowPreferredHeight(row, height) (shared captured text)
setRowSpacing function (self, row: int, spacing: float) -> None X.setRowSpacing(row, spacing) (shared captured text)
setRowStretchFactor function (self, row: int, stretch: int) -> None X.setRowStretchFactor(row, stretch) (shared captured text)
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. (shared captured text)
setVerticalSpacing function (self, spacing: float) -> None Sets the default vertical spacing for the grid layout to spacing. (shared captured text)
sizeHint function (self, which: Any, constraint: Any) -> Any X.sizeHint(which, constraint) -> PythonQt.QtCore.QSizeF (shared captured text)
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 (shared captured text)
widgetEvent function (self, e: Any) -> Any (shared captured text)