QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsLayoutObject Class Reference

A base class for objects which belong to a layout. More...

#include <qgslayoutobject.h>

Inheritance diagram for QgsLayoutObject:
Inheritance graph
[legend]

Public Types

enum  DataDefinedProperty {
  NoProperty = 0 , AllProperties , TestProperty , PresetPaperSize ,
  PaperWidth , PaperHeight , NumPages , PaperOrientation ,
  PageNumber , PositionX , PositionY , ItemWidth ,
  ItemHeight , ItemRotation , Transparency , Opacity ,
  BlendMode , ExcludeFromExports , FrameColor , BackgroundColor ,
  MapRotation , MapScale , MapXMin , MapYMin ,
  MapXMax , MapYMax , MapAtlasMargin , MapLayers ,
  MapStylePreset , MapLabelMargin , MapGridEnabled , MapGridIntervalX ,
  MapGridIntervalY , MapGridOffsetX , MapGridOffsetY , MapGridFrameSize ,
  MapGridFrameMargin , MapGridLabelDistance , MapGridCrossSize , MapGridFrameLineThickness ,
  MapGridAnnotationDisplayLeft , MapGridAnnotationDisplayRight , MapGridAnnotationDisplayTop , MapGridAnnotationDisplayBottom ,
  MapGridFrameDivisionsLeft , MapGridFrameDivisionsRight , MapGridFrameDivisionsTop , MapGridFrameDivisionsBottom ,
  PictureSource , PictureSvgBackgroundColor , PictureSvgStrokeColor , PictureSvgStrokeWidth ,
  SourceUrl , LegendTitle , LegendColumnCount , ScalebarFillColor ,
  ScalebarFillColor2 , ScalebarLineColor , ScalebarLineWidth , AttributeTableSourceLayer ,
  MapCrs , StartDateTime , EndDateTime
}
 Data defined properties for different item types. More...
 
enum  PropertyValueType { EvaluatedValue = 0 , OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...
 

Public Slots

virtual void refresh ()
 Refreshes the object, causing a recalculation of any property overrides. More...
 

Signals

void changed ()
 Emitted when the object's properties change. More...
 

Public Member Functions

 QgsLayoutObject (QgsLayout *layout)
 Constructor for QgsLayoutObject, with the specified parent layout. More...
 
QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the objects' current state. More...
 
QStringList customProperties () const
 Returns list of keys stored in custom properties for the object. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object. More...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
QgsLayoutlayout ()
 Returns the layout the object is attached to. More...
 
const QgsLayoutlayout () const
 Returns the layout the object is attached to. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object. More...
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the objects's property collection, used for data defined overrides. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Static Public Member Functions

static bool propertyAssociatesWithParentMultiframe (DataDefinedProperty property)
 Returns true if the specified property key is normally associated with the parent QgsLayoutMultiFrame object instead of a child QgsLayoutFrame object. More...
 
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the layout object property definitions. More...
 

Protected Member Functions

bool readObjectPropertiesFromElement (const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
 Sets object properties from a DOM element. More...
 
bool writeObjectPropertiesToElement (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
 Stores object properties within an XML DOM element. More...
 

Protected Attributes

QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QgsPropertyCollection mDataDefinedProperties
 
QPointer< QgsLayoutmLayout
 

Friends

class QgsCompositionConverter
 
class TestQgsLayoutObject
 

Detailed Description

A base class for objects which belong to a layout.

Since
QGIS 3.0

Definition at line 39 of file qgslayoutobject.h.

Member Enumeration Documentation

◆ DataDefinedProperty

Data defined properties for different item types.

Enumerator
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.

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.

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.

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.

MapCrs 

Map CRS.

StartDateTime 

Temporal range's start DateTime.

EndDateTime 

Temporal range's end DateTime.

Definition at line 132 of file qgslayoutobject.h.

◆ PropertyValueType

Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property.

This may differ if a property has a data defined expression active.

Enumerator
EvaluatedValue 

Return the current evaluated value for the property.

OriginalValue 

Return the original, user set value.

Definition at line 212 of file qgslayoutobject.h.

Constructor & Destructor Documentation

◆ QgsLayoutObject()

QgsLayoutObject::QgsLayoutObject ( QgsLayout layout)
explicit

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.

Definition at line 187 of file qgslayoutobject.cpp.

Member Function Documentation

◆ changed

void QgsLayoutObject::changed ( )
signal

Emitted when the object's properties change.

◆ createExpressionContext()

QgsExpressionContext QgsLayoutObject::createExpressionContext ( ) const
overridevirtual

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

The context includes scopes for global, project and layout properties.

Implements QgsExpressionContextGenerator.

Definition at line 230 of file qgslayoutobject.cpp.

◆ customProperties()

QStringList QgsLayoutObject::customProperties ( ) const

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

See also
setCustomProperty()
customProperty()
removeCustomProperty()

Definition at line 225 of file qgslayoutobject.cpp.

◆ customProperty()

QVariant QgsLayoutObject::customProperty ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

Read a custom property from the object.

Parameters
keyproperty key
defaultValuedefault value to return if property with matching key does not exist
Returns
value of matching property
See also
setCustomProperty()
removeCustomProperty()
customProperties()

Definition at line 215 of file qgslayoutobject.cpp.

◆ dataDefinedProperties() [1/2]

QgsPropertyCollection& QgsLayoutObject::dataDefinedProperties ( )
inline

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

See also
setDataDefinedProperties()

Definition at line 257 of file qgslayoutobject.h.

◆ dataDefinedProperties() [2/2]

const QgsPropertyCollection& QgsLayoutObject::dataDefinedProperties ( ) const
inline

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

See also
setDataDefinedProperties()
DataDefinedProperty

Definition at line 264 of file qgslayoutobject.h.

◆ layout() [1/2]

QgsLayout * QgsLayoutObject::layout ( )

Returns the layout the object is attached to.

Definition at line 205 of file qgslayoutobject.cpp.

◆ layout() [2/2]

const QgsLayout * QgsLayoutObject::layout ( ) const

Returns the layout the object is attached to.

Definition at line 200 of file qgslayoutobject.cpp.

◆ propertyAssociatesWithParentMultiframe()

bool QgsLayoutObject::propertyAssociatesWithParentMultiframe ( QgsLayoutObject::DataDefinedProperty  property)
static

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).

Since
QGIS 3.18.1

Definition at line 113 of file qgslayoutobject.cpp.

◆ propertyDefinitions()

const QgsPropertiesDefinition & QgsLayoutObject::propertyDefinitions ( )
static

Returns the layout object property definitions.

Definition at line 107 of file qgslayoutobject.cpp.

◆ readObjectPropertiesFromElement()

bool QgsLayoutObject::readObjectPropertiesFromElement ( const QDomElement &  parentElement,
const QDomDocument &  document,
const QgsReadWriteContext context 
)
protected

Sets object properties from a DOM element.

Parameters
parentElementis the parent DOM element for the object
documentDOM document
contextread write context
Returns
true if read was successful
See also
writeObjectPropertiesToElement()

Definition at line 263 of file qgslayoutobject.cpp.

◆ refresh

virtual void QgsLayoutObject::refresh ( )
inlinevirtualslot

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

Reimplemented in QgsLayoutItemMapGrid.

Definition at line 324 of file qgslayoutobject.h.

◆ removeCustomProperty()

void QgsLayoutObject::removeCustomProperty ( const QString &  key)

Remove a custom property from the object.

Parameters
keyproperty key
See also
setCustomProperty()
customProperty()
customProperties()

Definition at line 220 of file qgslayoutobject.cpp.

◆ setCustomProperty()

void QgsLayoutObject::setCustomProperty ( const QString &  key,
const QVariant &  value 
)

Set a custom property for the object.

Parameters
keyproperty key. If a property with the same key already exists it will be overwritten.
valueproperty value
See also
customProperty()
removeCustomProperty()
customProperties()

Definition at line 210 of file qgslayoutobject.cpp.

◆ setDataDefinedProperties()

void QgsLayoutObject::setDataDefinedProperties ( const QgsPropertyCollection collection)
inline

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

Parameters
collectionproperty collection. Existing properties will be replaced.
See also
dataDefinedProperties()
DataDefinedProperty

Definition at line 272 of file qgslayoutobject.h.

◆ writeObjectPropertiesToElement()

bool QgsLayoutObject::writeObjectPropertiesToElement ( QDomElement &  parentElement,
QDomDocument &  document,
const QgsReadWriteContext context 
) const
protected

Stores object properties within an XML DOM element.

Parameters
parentElementis the parent DOM element to store the object's properties in
documentDOM document
contextread write context
Returns
true if write was successful
See also
readObjectPropertiesFromElement()

Definition at line 242 of file qgslayoutobject.cpp.

Friends And Related Function Documentation

◆ QgsCompositionConverter

friend class QgsCompositionConverter
friend

Definition at line 370 of file qgslayoutobject.h.

◆ TestQgsLayoutObject

friend class TestQgsLayoutObject
friend

Definition at line 369 of file qgslayoutobject.h.

Member Data Documentation

◆ mCustomProperties

QgsObjectCustomProperties QgsLayoutObject::mCustomProperties
protected

Custom properties for object.

Definition at line 360 of file qgslayoutobject.h.

◆ mDataDefinedProperties

QgsPropertyCollection QgsLayoutObject::mDataDefinedProperties
protected

Definition at line 357 of file qgslayoutobject.h.

◆ mLayout

QPointer< QgsLayout > QgsLayoutObject::mLayout
protected

Definition at line 355 of file qgslayoutobject.h.


The documentation for this class was generated from the following files: