PythonQt.Qt.QGraphicsAnchorLayout
QGraphicsAnchorLayout
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
The anchor layout allows developers to specify how widgets should be placed relative to each other, and to the layout itself. The specification is made by adding anchors to the layout by calling addAnchor(), addAnchors() or addCornerAnchors().
Existing anchors in the layout can be accessed with the anchor() function. Items that are anchored are automatically added to the layout, and if items are removed, all their anchors will be automatically removed.

Anchors are always set up between edges of an item, where the "center" is also considered to be an edge. Consider the following example:
layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight);
layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom);
Here, the right edge of item a is anchored to the left edge of item b and the bottom
edge of item a is anchored to the top edge of item b, with the result that item b
will be placed diagonally to the right and below item b.
The addCornerAnchors() function provides a simpler way of anchoring the corners of two widgets than the two individual calls to addAnchor() shown in the code above. Here, we see how a widget can be anchored to the top-left corner of the enclosing layout:
layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);
In cases where anchors are used to match the widths or heights of widgets, it is convenient to use the addAnchors() function. As with the other functions for specifying anchors, it can also be used to anchor a widget to a layout.
Size Hints and Size Policies in an Anchor Layout
QGraphicsAnchorLayout respects each item's size hints and size policies. Note that there are some properties of QSizePolicy that are not respected.
Spacing within an Anchor Layout
The layout may distribute some space between the items. If the spacing has not been explicitly specified, the actual amount of space will usually be 0.
However, if the first edge is the opposite of the second edge (e.g., the right edge of the first widget is anchored to the left edge of the second widget), the size of the anchor will be queried from the style through a pixel metric: PM_LayoutHorizontalSpacing for horizontal anchors and PM_LayoutVerticalSpacing for vertical anchors.
If the spacing is negative, the items will overlap to some extent.
Known Issues
There are some features that QGraphicsAnchorLayout currently does not support. This might change in the future, so avoid using these features if you want to avoid any future regressions in behaviour:
- Stretch factors are not respected.
- QSizePolicy::ExpandFlag is not respected.
- Height for width is not respected.
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsanchorlayout.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) |
addAnchor |
function | (self, firstItem: Any, firstEdge: Any, secondItem: Any, secondEdge: Any) -> Any |
X.addAnchor(firstItem, firstEdge, secondItem, secondEdge) -> PythonQt.QtGui.QGraphicsAnchor (shared captured text) |
addAnchors |
function | (self, firstItem: Any, secondItem: Any, orientations: Any) -> None |
X.addAnchors(firstItem, secondItem, orientations) (shared captured text) |
addChildLayoutItem |
function | (self, layoutItem: Any) -> Any |
(shared captured text) |
addCornerAnchors |
function | (self, firstItem: Any, firstCorner: Any, secondItem: Any, secondCorner: Any) -> None |
X.addCornerAnchors(firstItem, firstCorner, secondItem, secondCorner) (shared captured text) |
anchor |
function | (self, firstItem: Any, firstEdge: Any, secondItem: Any, secondEdge: Any) -> Any |
X.anchor(firstItem, firstEdge, secondItem, secondEdge) -> PythonQt.QtGui.QGraphicsAnchor (shared captured text) |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (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: int) -> 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) |
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 anchor 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) |
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 default horizontal and the default vertical spacing for the anchor layout to spacing. (shared captured text) |
setVerticalSpacing |
function | (self, spacing: float) -> None |
Sets the default vertical spacing for the anchor 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) |