Class: QgsLayoutObject

class qgis.core.QgsLayoutObject(layout: QgsLayout)

Bases: PyQt5.QtCore.QObject, QgsExpressionContextGenerator

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.

A base class for objects which belong to a layout.

New in version 3.0.

Parameters

layout

AllProperties = 1
AttributeTableSourceLayer = 59
BackgroundColor = 19
BlendMode = 16
class DataDefinedProperty

Bases: int

EndDateTime = 62
EvaluatedValue = 0
ExcludeFromExports = 17
FrameColor = 18
ItemHeight = 12
ItemRotation = 13
ItemWidth = 11
LegendColumnCount = 54
LegendTitle = 53
MapAtlasMargin = 26
MapCrs = 60
MapGridAnnotationDisplayBottom = 43
MapGridAnnotationDisplayLeft = 40
MapGridAnnotationDisplayRight = 41
MapGridAnnotationDisplayTop = 42
MapGridCrossSize = 38
MapGridEnabled = 30
MapGridFrameDivisionsBottom = 47
MapGridFrameDivisionsLeft = 44
MapGridFrameDivisionsRight = 45
MapGridFrameDivisionsTop = 46
MapGridFrameLineThickness = 39
MapGridFrameMargin = 36
MapGridFrameSize = 35
MapGridIntervalX = 31
MapGridIntervalY = 32
MapGridLabelDistance = 37
MapGridOffsetX = 33
MapGridOffsetY = 34
MapLabelMargin = 29
MapLayers = 27
MapRotation = 20
MapScale = 21
MapStylePreset = 28
MapXMax = 24
MapXMin = 22
MapYMax = 25
MapYMin = 23
NoProperty = 0
NumPages = 6
Opacity = 15
OriginalValue = 1
PageNumber = 8
PaperHeight = 5
PaperOrientation = 7
PaperWidth = 4
PictureSource = 48
PictureSvgBackgroundColor = 49
PictureSvgStrokeColor = 50
PictureSvgStrokeWidth = 51
PositionX = 9
PositionY = 10
PresetPaperSize = 3
class PropertyValueType

Bases: int

ScalebarFillColor = 55
ScalebarFillColor2 = 56
ScalebarLineColor = 57
ScalebarLineWidth = 58
SourceUrl = 52
StartDateTime = 61
TestProperty = 2
Transparency = 14
changed

Emitted when the object’s properties change. [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).

New 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