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 = 51
BackgroundColor = 19
BlendMode = 16
class DataDefinedProperty

Bases: int

EvaluatedValue = 0
ExcludeFromExports = 17
FrameColor = 18
ItemHeight = 12
ItemRotation = 13
ItemWidth = 11
LegendColumnCount = 46
LegendTitle = 45
MapAtlasMargin = 26
MapGridCrossSize = 38
MapGridEnabled = 30
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 = 40
PictureSvgBackgroundColor = 41
PictureSvgStrokeColor = 42
PictureSvgStrokeWidth = 43
PositionX = 9
PositionY = 10
PresetPaperSize = 3
class PropertyValueType

Bases: int

ScalebarFillColor = 47
ScalebarFillColor2 = 48
ScalebarLineColor = 49
ScalebarLineWidth = 50
SourceUrl = 44
TestProperty = 2
Transparency = 14
changed

Emitted when the object’s properties change. [signal]

childEvent()
connectNotify()
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()
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()
isSignalConnected()
layout(self) → QgsLayout

Returns the layout the object is attached to.

Return type

QgsLayout

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()
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()
senderSignalIndex()
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()
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