Class: QgsLayoutItemShape

Layout item for basic filled shapes (e.g. rectangles, ellipses).

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutItemShape

Base classes

QgsLayoutItem

Base class for graphical items within a QgsLayout.

QgsLayoutObject

A base class for objects which belong to a layout.

QObject

QgsExpressionContextGenerator

Abstract interface for generating an expression context.

QGraphicsRectItem

QAbstractGraphicsShapeItem

QGraphicsItem

QgsLayoutUndoObjectInterface

Interface for layout objects which support undo/redo commands.

Methods

cornerRadius

Returns the corner radius for rounded rectangle corners.

setCornerRadius

Sets the corner radius for rounded rectangle corners.

setShapeType

Sets the type of shape (e.g. rectangle, ellipse, etc).

setSymbol

Sets the fill symbol used to draw the shape.

shapeType

Returns the type of shape (e.g. rectangle, ellipse, etc).

symbol

Returns the fill symbol used to draw the shape.

Static Methods

create

Returns a new shape item for the specified layout.

Attributes

Ellipse

Rectangle

Triangle

class qgis.core.QgsLayoutItemShape[source]

Bases: QgsLayoutItem

__init__(layout: QgsLayout | None)

Constructor for QgsLayoutItemShape, with the specified parent layout.

Parameters:

layout (Optional[QgsLayout])

Ellipse = 0
Rectangle = 1
class Shape

Bases: int

Triangle = 2
cornerRadius(self) QgsLayoutMeasurement[source]

Returns the corner radius for rounded rectangle corners.

Return type:

QgsLayoutMeasurement

static create(layout: QgsLayout | None) QgsLayoutItemShape | None[source]

Returns a new shape item for the specified layout.

The caller takes responsibility for deleting the returned object.

Parameters:

layout (Optional[QgsLayout])

Return type:

Optional[QgsLayoutItemShape]

setCornerRadius(self, radius: QgsLayoutMeasurement)[source]

Sets the corner radius for rounded rectangle corners.

See also

cornerRadius()

Parameters:

radius (QgsLayoutMeasurement)

setShapeType(self, type: QgsLayoutItemShape.Shape)[source]

Sets the type of shape (e.g. rectangle, ellipse, etc).

See also

shapeType()

Parameters:

type (QgsLayoutItemShape.Shape)

setSymbol(self, symbol: QgsFillSymbol | None)[source]

Sets the fill symbol used to draw the shape. Ownership is not transferred and a clone of the symbol is made.

See also

symbol()

Parameters:

symbol (Optional[QgsFillSymbol])

shapeType(self) QgsLayoutItemShape.Shape[source]

Returns the type of shape (e.g. rectangle, ellipse, etc).

See also

setShapeType()

Return type:

QgsLayoutItemShape.Shape

symbol(self) QgsFillSymbol | None[source]

Returns the fill symbol used to draw the shape.

See also

setSymbol()

Return type:

Optional[QgsFillSymbol]