Class: QgsLayoutObject¶
A base class for objects which belong to a layout.
Class Hierarchy¶
Base classes¶
Abstract interface for generating an expression context.  | 
Subclasses¶
Base class for graphical items within a   | 
|
Abstract base class for layout items with the ability to distribute the content to several frames (  | 
|
An item which is drawn inside a   | 
Enums
Data defined properties for different item types  | 
Methods
Creates an expression context relating to the objects' current state.  | 
|
Returns list of keys stored in custom properties for the object.  | 
|
Read a custom property from the object.  | 
|
Returns a reference to the object's property collection, used for data defined overrides.  | 
|
Returns the layout the object is attached to.  | 
|
Returns the layout object property definitions.  | 
|
Sets object properties from a DOM element  | 
|
Refreshes the object, causing a recalculation of any property overrides.  | 
|
Remove a custom property from the object.  | 
|
Set a custom property for the object.  | 
|
Sets the objects's property collection, used for data defined overrides.  | 
|
Stores object properties within an XML DOM element.  | 
Static Methods
Returns   | 
Signals
Emitted when the object's properties change.  | 
Attributes
- class qgis.core.QgsLayoutObject[source]¶
 Bases:
QObject,QgsExpressionContextGenerator- __init__(layout: QgsLayout | None)
 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.
- Parameters:
 layout (Optional[QgsLayout])
- class DataDefinedProperty(*values)¶
 Bases:
IntEnumData defined properties for different item types
NoProperty: No propertyAllProperties: All properties for itemTestProperty: Dummy property with no effect on itemPresetPaperSize: Preset paper size for compositionPaperWidth: Paper width (deprecated)PaperHeight: Paper height (deprecated)NumPages: Number of pages in composition (deprecated)PaperOrientation: Paper orientationPageNumber: Page number for item placementPositionX: X position on pagePositionY: Y position on pageItemWidth: Width of itemItemHeight: Height of itemItemRotation: Rotation of itemTransparency: Item transparency (deprecated)Opacity: Item opacityBlendMode: Item blend modeExcludeFromExports: Exclude item from exportsFrameColor: Item frame colorBackgroundColor: Item background colorMarginLeft: Left marginAdded in version 3.30.
MarginTop: Top marginAdded in version 3.30.
MarginRight: Right marginAdded in version 3.30.
MarginBottom: Bottom marginAdded in version 3.30.
MapRotation: Map rotationMapScale: Map scaleMapXMin: Map extent x minimumMapYMin: Map extent y minimumMapXMax: Map extent x maximumMapYMax: Map extent y maximumMapAtlasMargin: Map atlas marginMapLayers: Map layer setMapStylePreset: Layer and style map themeMapLabelMargin: Map label marginMapGridEnabled: Map grid enabledMapGridIntervalX: Map grid interval XMapGridIntervalY: Map grid interval YMapGridOffsetX: Map grid offset XMapGridOffsetY: Map grid offset YMapGridFrameSize: Map grid frame sizeMapGridFrameMargin: Map grid frame marginMapGridLabelDistance: Map grid label distanceMapGridCrossSize: Map grid cross sizeMapGridFrameLineThickness: Map grid frame line thicknessMapGridAnnotationDisplayLeft: Map annotation display leftMapGridAnnotationDisplayRight: Map annotation display rightMapGridAnnotationDisplayTop: Map annotation display topMapGridAnnotationDisplayBottom: Map annotation display bottomMapGridFrameDivisionsLeft: Map frame division display leftMapGridFrameDivisionsRight: Map frame division display rightMapGridFrameDivisionsTop: Map frame division display topMapGridFrameDivisionsBottom: Map frame division display bottomMapCrs: Map CRSStartDateTime: Temporal range’s start DateTimeEndDateTime: Temporal range’s end DateTimeMapZRangeLower: Map frame Z-range lower valueAdded in version 3.38.
MapZRangeUpper: Map frame Z-range lower valueAdded in version 3.38.
PictureSource: Picture source urlPictureSvgBackgroundColor: SVG background colorPictureSvgStrokeColor: SVG stroke colorPictureSvgStrokeWidth: SVG stroke widthSourceUrl: Html source urlLegendTitle: Legend titleLegendColumnCount: Legend column countScalebarLeftSegments: Number of segments on the left of 0Added in version 3.26.
ScalebarRightSegments: Number of segments on the right of 0Added in version 3.26.
ScalebarSegmentWidth: Scalebar width in map units of a single segmentAdded in version 3.26.
ScalebarMinimumWidth: Scalebar segment minimum widthAdded in version 3.26.
ScalebarMaximumWidth: Scalebar segment maximum widthAdded in version 3.26.
ScalebarHeight: Scalebar heightAdded in version 3.26.
ScalebarRightSegmentSubdivisions: Number of subdivisions per segment on right of 0Added in version 3.26.
ScalebarSubdivisionHeight: Scalebar subdivision heightAdded in version 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 layerElevationProfileTolerance: Tolerance distance for elevation profilesAdded in version 3.30.
ElevationProfileDistanceMajorInterval: Major grid line interval for elevation profile distance axisAdded in version 3.30.
ElevationProfileDistanceMinorInterval: Minor grid line interval for elevation profile distance axisAdded in version 3.30.
ElevationProfileDistanceLabelInterval: Label interval for elevation profile distance axisAdded in version 3.30.
ElevationProfileElevationMajorInterval: Major grid line interval for elevation profile elevation axisAdded in version 3.30.
ElevationProfileElevationMinorInterval: Minor grid line interval for elevation profile elevation axisAdded in version 3.30.
ElevationProfileElevationLabelInterval: Label interval for elevation profile elevation axisAdded in version 3.30.
ElevationProfileMinimumDistance: Minimum distance value for elevation profileAdded in version 3.30.
ElevationProfileMaximumDistance: Maximum distance value for elevation profileAdded in version 3.30.
ElevationProfileMinimumElevation: Minimum elevation value for elevation profileAdded in version 3.30.
ElevationProfileMaximumElevation: Maximum elevation value for elevation profileAdded in version 3.30.
- EvaluatedValue = 0¶
 
- OriginalValue = 1¶
 
- class PropertyValueType¶
 Bases:
int
- createExpressionContext(self) QgsExpressionContext[source]¶
 Creates an expression context relating to the objects’ current state. The context includes scopes for global, project and layout properties.
- Return type:
 
- customProperties(self) List[str][source]¶
 Returns list of keys stored in custom properties for the object.
See also
See also
See also
- Return type:
 List[str]
- customProperty(self, key: str | None, defaultValue: Any = None) Any[source]¶
 Read a custom property from the object.
- Parameters:
 key (Optional[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
See also
See also
See also
- dataDefinedProperties(self) QgsPropertyCollection¶
 Returns a reference to the object’s property collection, used for data defined overrides.
See also
- Return type:
 
- layout(self) QgsLayout | None[source]¶
 Returns the layout the object is attached to.
- Return type:
 Optional[QgsLayout]
- static propertyAssociatesWithParentMultiframe(property: QgsLayoutObject.DataDefinedProperty) bool[source]¶
 Returns
Trueif the specifiedpropertykey is normally associated with the parentQgsLayoutMultiFrameobject instead of a childQgsLayoutFrameobject.While some properties like QgsLayoutObject.DataDefinedProperty.PositionX and QgsLayoutObject.DataDefinedProperty.ItemWidth are typically associated with a direct
QgsLayoutItemsubclass (includingQgsLayoutFrameobjects), other properties are instead associated with aQgsLayoutMultiFrameobject (such asQgsLayoutObject.DataDefinedProperty.SourceUrl orQgsLayoutObject.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[source]¶
 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:
 Trueif read was successful
See also
- removeCustomProperty(self, key: str | None)[source]¶
 Remove a custom property from the object.
- Parameters:
 key (Optional[str]) – property key
See also
See also
See also
- setCustomProperty(self, key: str | None, value: Any)[source]¶
 Set a custom property for the object.
- Parameters:
 key (Optional[str]) – property key. If a property with the same key already exists it will be overwritten.
value (Any) – property value
See also
See also
See also
- setDataDefinedProperties(self, collection: QgsPropertyCollection)[source]¶
 Sets the objects’s property collection, used for data defined overrides.
- Parameters:
 collection (QgsPropertyCollection) – property collection. Existing properties will be replaced.
See also
See also
DataDefinedProperty
- writeObjectPropertiesToElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool[source]¶
 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:
 Trueif write was successful
See also