Subgroup: Layout

Class: QgsLayoutObject

class qgis.core.QgsLayoutObject(layout: QgsLayout)

Bases: PyQt5.QtCore.QObject, qgis._core.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: Methods

childEvent
connectNotify
createExpressionContext Creates an expression context relating to the objects’ current state.
customEvent
customProperties Return 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.
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 Emitted when the object’s properties change.

Attributes

AllProperties
AttributeTableSourceLayer
BackgroundColor
BlendMode
EvaluatedValue
ExcludeFromExports
FrameColor
ItemHeight
ItemRotation
ItemWidth
LegendColumnCount
LegendTitle
MapAtlasMargin
MapLayers
MapRotation
MapScale
MapStylePreset
MapXMax
MapXMin
MapYMax
MapYMin
NoProperty
NumPages
Opacity
OriginalValue
PageNumber
PaperHeight
PaperOrientation
PaperWidth
PictureSource
PictureSvgBackgroundColor
PictureSvgStrokeColor
PictureSvgStrokeWidth
PositionX
PositionY
PresetPaperSize
ScalebarFillColor
ScalebarFillColor2
ScalebarLineColor
ScalebarLineWidth
SourceUrl
TestProperty
Transparency
AllProperties = 1
AttributeTableSourceLayer = 40
BackgroundColor = 19
BlendMode = 16
class DataDefinedProperty

Bases: int

EvaluatedValue = 0
ExcludeFromExports = 17
FrameColor = 18
ItemHeight = 12
ItemRotation = 13
ItemWidth = 11
LegendColumnCount = 35
LegendTitle = 34
MapAtlasMargin = 26
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 = 29
PictureSvgBackgroundColor = 30
PictureSvgStrokeColor = 31
PictureSvgStrokeWidth = 32
PositionX = 9
PositionY = 10
PresetPaperSize = 3
class PropertyValueType

Bases: int

ScalebarFillColor = 36
ScalebarFillColor2 = 37
ScalebarLineColor = 38
ScalebarLineWidth = 39
SourceUrl = 33
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.

customEvent()
customProperties(self) → List[str]

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

See also

customProperty()

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

Read a custom property from the object.

Parameters:
  • key – property key
  • defaultValue – default value to return if property with matching key does not exist
Returns:

value of matching property

dataDefinedProperties(self) → QgsPropertyCollection

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

disconnectNotify()
isSignalConnected()
layout(self) → QgsLayout

Returns the layout the object is attached to.

propertyDefinitions() → object

Returns the layout object property definitions.

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

Sets object properties from a DOM element

Parameters:
  • parentElement – is the parent DOM element for the object
  • document – DOM document
  • context – read write context
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 – property key

See also

customProperty()

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

Set a custom property for the object.

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

See also

customProperty()

setDataDefinedProperties(self, collection: QgsPropertyCollection)

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

Parameters:collection – property collection. Existing properties will be replaced.
timerEvent()
writeObjectPropertiesToElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool

Stores object properties within an XML DOM element.

Parameters:
  • parentElement – is the parent DOM element to store the object’s properties in
  • document – DOM document
  • context – read write context
Returns:

true if write was successful