Class: QgsLayoutObject

class qgis.core.QgsLayoutObject

Bases: PyQt5.QtCore.QObject, QgsExpressionContextGenerator

A base class for objects which belong to a layout.

QgsLayoutObject(layout: QgsLayout) Constructor for QgsLayoutObject, with the specified parent layout.

Note

While ownership of a QgsLayoutObject is not passed to the layout, classes which are derived from QgsLayoutObject (such as QgsLayoutItem) may transfer their ownership to a layout upon construction.

Enums

DataDefinedProperty

Bases: enum.IntEnum

Methods

childEvent

connectNotify

createExpressionContext

Creates an expression context relating to the objects' current state.

customEvent

customProperties

Returns list of keys stored in custom properties for the object.

customProperty

Read a custom property from the object.

dataDefinedProperties

Returns a reference to the object's property collection, used for data defined overrides.

disconnectNotify

isSignalConnected

layout

Returns the layout the object is attached to.

propertyAssociatesWithParentMultiframe

Returns True if the specified property key is normally associated with the parent QgsLayoutMultiFrame object instead of a child QgsLayoutFrame object.

propertyDefinitions

Returns the layout object property definitions.

readObjectPropertiesFromElement

Sets object properties from a DOM element

receivers

refresh

Refreshes the object, causing a recalculation of any property overrides.

removeCustomProperty

Remove a custom property from the object.

sender

senderSignalIndex

setCustomProperty

Set a custom property for the object.

setDataDefinedProperties

Sets the objects's property collection, used for data defined overrides.

timerEvent

writeObjectPropertiesToElement

Stores object properties within an XML DOM element.

Signals

changed

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

Attributes

EvaluatedValue

OriginalValue

class DataDefinedProperty(value)

Bases: enum.IntEnum

Data defined properties for different item types

  • NoProperty: No property

  • AllProperties: All properties for item

  • TestProperty: Dummy property with no effect on item

  • PresetPaperSize: Preset paper size for composition

  • PaperWidth: Paper width (deprecated)

  • PaperHeight: Paper height (deprecated)

  • NumPages: Number of pages in composition (deprecated)

  • PaperOrientation: Paper orientation

  • PageNumber: Page number for item placement

  • PositionX: X position on page

  • PositionY: Y position on page

  • ItemWidth: Width of item

  • ItemHeight: Height of item

  • ItemRotation: Rotation of item

  • Transparency: Item transparency (deprecated)

  • Opacity: Item opacity

  • BlendMode: Item blend mode

  • ExcludeFromExports: Exclude item from exports

  • FrameColor: Item frame color

  • BackgroundColor: Item background color

  • MarginLeft: Left margin (since QGIS 3.30)

  • MarginTop: Top margin (since QGIS 3.30)

  • MarginRight: Right margin (since QGIS 3.30)

  • MarginBottom: Bottom margin (since QGIS 3.30)

  • MapRotation: Map rotation

  • MapScale: Map scale

  • MapXMin: Map extent x minimum

  • MapYMin: Map extent y minimum

  • MapXMax: Map extent x maximum

  • MapYMax: Map extent y maximum

  • MapAtlasMargin: Map atlas margin

  • MapLayers: Map layer set

  • MapStylePreset: Layer and style map theme

  • MapLabelMargin: Map label margin

  • MapGridEnabled: Map grid enabled

  • MapGridIntervalX: Map grid interval X

  • MapGridIntervalY: Map grid interval Y

  • MapGridOffsetX: Map grid offset X

  • MapGridOffsetY: Map grid offset Y

  • MapGridFrameSize: Map grid frame size

  • MapGridFrameMargin: Map grid frame margin

  • MapGridLabelDistance: Map grid label distance

  • MapGridCrossSize: Map grid cross size

  • MapGridFrameLineThickness: Map grid frame line thickness

  • MapGridAnnotationDisplayLeft: Map annotation display left

  • MapGridAnnotationDisplayRight: Map annotation display right

  • MapGridAnnotationDisplayTop: Map annotation display top

  • MapGridAnnotationDisplayBottom: Map annotation display bottom

  • MapGridFrameDivisionsLeft: Map frame division display left

  • MapGridFrameDivisionsRight: Map frame division display right

  • MapGridFrameDivisionsTop: Map frame division display top

  • MapGridFrameDivisionsBottom: Map frame division display bottom

  • MapCrs: Map CRS

  • StartDateTime: Temporal range’s start DateTime

  • EndDateTime: Temporal range’s end DateTime

  • MapZRangeLower: Map frame Z-range lower value (since QGIS 3.38)

  • MapZRangeUpper: Map frame Z-range lower value (since QGIS 3.38)

  • PictureSource: Picture source url

  • PictureSvgBackgroundColor: SVG background color

  • PictureSvgStrokeColor: SVG stroke color

  • PictureSvgStrokeWidth: SVG stroke width

  • SourceUrl: Html source url

  • LegendTitle: Legend title

  • LegendColumnCount: Legend column count

  • ScalebarLeftSegments: Number of segments on the left of 0 (since QGIS 3.26)

  • ScalebarRightSegments: Number of segments on the right of 0 (since QGIS 3.26)

  • ScalebarSegmentWidth: Scalebar width in map units of a single segment (since QGIS 3.26)

  • ScalebarMinimumWidth: Scalebar segment minimum width (since QGIS 3.26)

  • ScalebarMaximumWidth: Scalebar segment maximum width (since QGIS 3.26)

  • ScalebarHeight: Scalebar height (since QGIS 3.26)

  • ScalebarRightSegmentSubdivisions: Number of subdivisions per segment on right of 0 (since QGIS 3.26)

  • ScalebarSubdivisionHeight: Scalebar subdivision height (since QGIS 3.26)

  • ScalebarFillColor: Scalebar fill color (deprecated, use data defined properties on scalebar fill symbol 1 instead)

  • ScalebarFillColor2: Scalebar secondary fill color (deprecated, use data defined properties on scalebar fill symbol 2 instead)

  • ScalebarLineColor: Scalebar line color (deprecated, use data defined properties on scalebar line symbol instead)

  • ScalebarLineWidth: Scalebar line width (deprecated, use data defined properties on scalebar line symbol instead)

  • AttributeTableSourceLayer: Attribute table source layer

  • ElevationProfileTolerance: Tolerance distance for elevation profiles (since QGIS 3.30)

  • ElevationProfileDistanceMajorInterval: Major grid line interval for elevation profile distance axis (since QGIS 3.30)

  • ElevationProfileDistanceMinorInterval: Minor grid line interval for elevation profile distance axis (since QGIS 3.30)

  • ElevationProfileDistanceLabelInterval: Label interval for elevation profile distance axis (since QGIS 3.30)

  • ElevationProfileElevationMajorInterval: Major grid line interval for elevation profile elevation axis (since QGIS 3.30)

  • ElevationProfileElevationMinorInterval: Minor grid line interval for elevation profile elevation axis (since QGIS 3.30)

  • ElevationProfileElevationLabelInterval: Label interval for elevation profile elevation axis (since QGIS 3.30)

  • ElevationProfileMinimumDistance: Minimum distance value for elevation profile (since QGIS 3.30)

  • ElevationProfileMaximumDistance: Maximum distance value for elevation profile (since QGIS 3.30)

  • ElevationProfileMinimumElevation: Minimum elevation value for elevation profile (since QGIS 3.30)

  • ElevationProfileMaximumElevation: Maximum elevation value for elevation profile (since QGIS 3.30)

EvaluatedValue = 0
OriginalValue = 1
class PropertyValueType

Bases: int

changed

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
createExpressionContext(self) QgsExpressionContext

Creates an expression context relating to the objects’ current state. The context includes scopes for global, project and layout properties.

Return type:

QgsExpressionContext

customEvent(self, QEvent)
customProperties(self) List[str]

Returns list of keys stored in custom properties for the object.

See also

customProperty()

Return type:

List[str]

customProperty(self, key: str, defaultValue: Any = None) Any

Read a custom property from the object.

Parameters:
  • key (str) – property key

  • defaultValue (Any = None) – default value to return if property with matching key does not exist

Return type:

Any

Returns:

value of matching property

dataDefinedProperties(self) QgsPropertyCollection

Returns a reference to the object’s property collection, used for data defined overrides.

Return type:

QgsPropertyCollection

disconnectNotify(self, QMetaMethod)
isSignalConnected(self, QMetaMethod) bool
layout(self) QgsLayout

Returns the layout the object is attached to.

Return type:

QgsLayout

propertyAssociatesWithParentMultiframe(property: QgsLayoutObject.DataDefinedProperty) bool

Returns True if the specified property key is normally associated with the parent QgsLayoutMultiFrame object instead of a child QgsLayoutFrame object.

While some properties like QgsLayoutObject.DataDefinedProperty.PositionX and QgsLayoutObject.DataDefinedProperty.ItemWidth are typically associated with a direct QgsLayoutItem subclass (including QgsLayoutFrame objects), other properties are instead associated with a QgsLayoutMultiFrame object (such as QgsLayoutObject.DataDefinedProperty.SourceUrl or QgsLayoutObject.DataDefinedProperty.AttributeTableSourceLayer).

Added in version 3.18.1.

Parameters:

property (QgsLayoutObject.DataDefinedProperty)

Return type:

bool

propertyDefinitions() Dict[int, QgsPropertyDefinition]

Returns the layout object property definitions.

Return type:

Dict[int, QgsPropertyDefinition]

readObjectPropertiesFromElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Sets object properties from a DOM element

Parameters:
  • parentElement (QDomElement) – is the parent DOM element for the object

  • document (QDomDocument) – DOM document

  • context (QgsReadWriteContext) – read write context

Return type:

bool

Returns:

True if read was successful

receivers(self, PYQT_SIGNAL) int
refresh(self)

Refreshes the object, causing a recalculation of any property overrides.

removeCustomProperty(self, key: str)

Remove a custom property from the object.

Parameters:

key (str) – property key

See also

customProperty()

sender(self) QObject
senderSignalIndex(self) int
setCustomProperty(self, key: str, value: Any)

Set a custom property for the object.

Parameters:
  • key (str) – property key. If a property with the same key already exists it will be overwritten.

  • value (Any) – property value

See also

customProperty()

setDataDefinedProperties(self, collection: QgsPropertyCollection)

Sets the objects’s property collection, used for data defined overrides.

Parameters:

collection (QgsPropertyCollection) – property collection. Existing properties will be replaced.

See also

DataDefinedProperty

timerEvent(self, QTimerEvent)
writeObjectPropertiesToElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Stores object properties within an XML DOM element.

Parameters:
  • parentElement (QDomElement) – is the parent DOM element to store the object’s properties in

  • document (QDomDocument) – DOM document

  • context (QgsReadWriteContext) – read write context

Return type:

bool

Returns:

True if write was successful