Class: QgsLayoutRenderContext

class qgis.core.QgsLayoutRenderContext

Bases: PyQt5.QtCore.QObject

Stores information relating to the current rendering settings for a layout.

QgsLayoutRenderContext(layout: QgsLayout) Constructor for QgsLayoutRenderContext.

Methods

boundingBoxesVisible

Returns True if the item bounding boxes should be drawn.

childEvent

connectNotify

currentExportLayer

Returns the current item layer to draw while exporting.

customEvent

disconnectNotify

dpi

Returns the dpi for outputting the layout.

exportThemes

Returns a list of map themes to use during the export.

featureFilterProvider

Returns the possibly NULL feature filter provider.

flags

Returns the current combination of flags used for rendering the layout.

gridVisible

Returns True if the page grid should be drawn.

isPreviewRender

Returns True if the render current being conducted is a preview render, i.e. it is being rendered inside a QGraphicsView widget as opposed to a destination device (such as an image).

isSignalConnected

measurementConverter

Returns the layout measurement converter to be used in the layout.

pagesVisible

Returns whether the page items are be visible in the layout.

predefinedScales

Returns the current list of predefined scales for use with the layout.

receivers

renderContextFlags

Returns the combination of render context flags matched to the layout context's settings.

selectionColor

Gets color that is used for drawing of selected vector features

sender

senderSignalIndex

setBoundingBoxesVisible

Sets whether the item bounding boxes should be visible.

setCurrentExportLayer

Sets the current item layer to draw while exporting.

setDpi

Sets the dpi for outputting the layout.

setExportThemes

Sets a list of map themes to use during the export.

setFeatureFilterProvider

Sets feature filter provider to featureFilterProvider.

setFlag

Enables or disables a particular rendering flag for the layout.

setFlags

Sets the combination of flags that will be used for rendering the layout.

setGridVisible

Sets whether the page grid should be visible.

setPagesVisible

Sets whether the page items should be visible in the layout.

setPredefinedScales

Sets the list of predefined scales to use with the layout.

setSelectionColor

Sets color that is used for drawing of selected vector features

setSimplifyMethod

Sets the simplification setting to use when rendering vector layers.

setTextRenderFormat

Sets the text render format, which dictates how text is rendered (e.g. as paths or real text objects).

simplifyMethod

Returns the simplification settings to use when rendering vector layers.

testFlag

Check whether a particular rendering flag is enabled for the layout.

textRenderFormat

Returns the text render format, which dictates how text is rendered (e.g. as paths or real text objects).

timerEvent

Signals

dpiChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

flagsChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

predefinedScalesChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

Attributes

FlagAntialiasing

FlagDebug

FlagDisableTiledRasterLayerRenders

FlagDrawSelection

FlagForceVectorOutput

FlagHideCoverageLayer

FlagLosslessImageRendering

FlagOutlineOnly

FlagRenderLabelsByMapLayer

FlagSynchronousLegendGraphics

FlagUseAdvancedEffects

class Flag

Bases: int

FlagAntialiasing = 8
FlagDebug = 2
FlagDisableTiledRasterLayerRenders = 256
FlagDrawSelection = 128
FlagForceVectorOutput = 32
FlagHideCoverageLayer = 64
FlagLosslessImageRendering = 1024
FlagOutlineOnly = 4
FlagRenderLabelsByMapLayer = 512
FlagSynchronousLegendGraphics = 2048
FlagUseAdvancedEffects = 16
class Flags
class Flags(Union[QgsLayoutRenderContext.Flags, QgsLayoutRenderContext.Flag])
class Flags(QgsLayoutRenderContext.Flags)

Bases: sip.wrapper

boundingBoxesVisible(self) bool

Returns True if the item bounding boxes should be drawn.

Return type:

bool

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
currentExportLayer(self) int

Returns the current item layer to draw while exporting. QgsLayoutItem subclasses which support multi-layer SVG exports must check this and customize their rendering based on the layer.

If layer is -1, all item layers should be rendered.

Deprecated since version Items: should now handle this themselves, via QgsLayoutItem.exportLayerBehavior() and returning QgsLayoutItem.nextExportPart().

Return type:

int

customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
dpi(self) float

Returns the dpi for outputting the layout.

See also

setDpi()

Return type:

float

dpiChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

exportThemes(self) List[str]

Returns a list of map themes to use during the export.

Items which handle layered exports (e.g. maps) may utilize this list to export different representations of the item as export layers, as they iterate through these included themes.

New in version 3.10.

Return type:

List[str]

featureFilterProvider(self) QgsFeatureFilterProvider

Returns the possibly NULL feature filter provider.

A feature filter provider for filtering visible features or attributes. It is currently used by QGIS Server Access Control Plugins.

New in version 3.18.

Return type:

QgsFeatureFilterProvider

flags(self) QgsLayoutRenderContext.Flags

Returns the current combination of flags used for rendering the layout.

See also

setFlags()

See also

setFlag()

See also

testFlag()

Return type:

QgsLayoutRenderContext.Flags

flagsChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

gridVisible(self) bool

Returns True if the page grid should be drawn.

See also

setGridVisible()

Return type:

bool

isPreviewRender(self) bool

Returns True if the render current being conducted is a preview render, i.e. it is being rendered inside a QGraphicsView widget as opposed to a destination device (such as an image).

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
measurementConverter(self) QgsLayoutMeasurementConverter

Returns the layout measurement converter to be used in the layout. This converter is used for translating between other measurement units and the layout’s native unit.

Return type:

QgsLayoutMeasurementConverter

pagesVisible(self) bool

Returns whether the page items are be visible in the layout. This setting effects both display of the page boundaries in layout views and whether they will be rendered in layout exports.

Return type:

bool

predefinedScales(self) List[float]

Returns the current list of predefined scales for use with the layout.

New in version 3.10.

Return type:

List[float]

predefinedScalesChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

receivers(self, PYQT_SIGNAL) int
renderContextFlags(self) Qgis.RenderContextFlags

Returns the combination of render context flags matched to the layout context’s settings.

Return type:

Qgis.RenderContextFlags

selectionColor(self) QColor

Gets color that is used for drawing of selected vector features

New in version 3.4.

Return type:

QColor

sender(self) QObject
senderSignalIndex(self) int
setBoundingBoxesVisible(self, visible: bool)

Sets whether the item bounding boxes should be visible.

Parameters:

visible (bool) –

setCurrentExportLayer(self, layer: int = -1)

Sets the current item layer to draw while exporting. QgsLayoutItem subclasses which support multi-layer SVG exports must check the currentExportLayer() and customize their rendering based on the layer.

If layer is -1, all item layers will be rendered.

Deprecated since version Items: should now handle this themselves, via QgsLayoutItem.exportLayerBehavior() and returning QgsLayoutItem.nextExportPart().

Parameters:

layer (int = -1) –

setDpi(self, dpi: float)

Sets the dpi for outputting the layout. This also sets the corresponding DPI for the context’s measurementConverter().

See also

dpi()

Parameters:

dpi (float) –

setExportThemes(self, themes: Iterable[str])

Sets a list of map themes to use during the export.

Items which handle layered exports (e.g. maps) may utilize this list to export different representations of the item as export layers, as they iterate through these included themes.

See also

exportThemes()

New in version 3.10.

Parameters:

themes (Iterable[str]) –

setFeatureFilterProvider(self, featureFilterProvider: QgsFeatureFilterProvider)

Sets feature filter provider to featureFilterProvider.

A feature filter provider for filtering visible features or attributes. It is currently used by QGIS Server Access Control Plugins.

New in version 3.18.

Parameters:

featureFilterProvider (QgsFeatureFilterProvider) –

setFlag(self, flag: QgsLayoutRenderContext.Flag, on: bool = True)

Enables or disables a particular rendering flag for the layout. Other existing flags are not affected.

See also

setFlags()

See also

flags()

See also

testFlag()

Parameters:
setFlags(self, flags: QgsLayoutRenderContext.Flags | QgsLayoutRenderContext.Flag)

Sets the combination of flags that will be used for rendering the layout.

See also

setFlag()

See also

flags()

See also

testFlag()

Parameters:

flags (Union[QgsLayoutRenderContext.Flags) –

setGridVisible(self, visible: bool)

Sets whether the page grid should be visible.

See also

gridVisible()

Parameters:

visible (bool) –

setPagesVisible(self, visible: bool)

Sets whether the page items should be visible in the layout. Removing them will prevent both display of the page boundaries in layout views and will also prevent them from being rendered in layout exports.

See also

pagesVisible()

Parameters:

visible (bool) –

setPredefinedScales(self, scales: Iterable[float])

Sets the list of predefined scales to use with the layout. This is used for maps which are set to the predefined atlas scaling mode.

New in version 3.10.

Parameters:

scales (Iterable[float]) –

setSelectionColor(self, color: QColor | Qt.GlobalColor | QGradient)

Sets color that is used for drawing of selected vector features

See also

selectionColor()

New in version 3.4.

Parameters:

color (Union[QColor) –

setSimplifyMethod(self, method: QgsVectorSimplifyMethod)

Sets the simplification setting to use when rendering vector layers.

If the simplify method is enabled, it apply to all vector layers rendered inside map items.

This can be used to specify global simplification methods to apply during map exports, e.g. to allow vector layers to be simplified to an appropriate maximum level of detail during PDF exports (avoiding excessive PDF size due to huge numbers of vertices).

The default is to use no simplification.

Note

This simplification method is only used during non-preview renders.

See also

simplifyMethod()

New in version 3.10.

Parameters:

method (QgsVectorSimplifyMethod) –

setTextRenderFormat(self, format: Qgis.TextRenderFormat)

Sets the text render format, which dictates how text is rendered (e.g. as paths or real text objects).

New in version 3.4.3.

Parameters:

format (Qgis.TextRenderFormat) –

simplifyMethod(self) QgsVectorSimplifyMethod

Returns the simplification settings to use when rendering vector layers.

If enabled, it will apply to all vector layers rendered for the map.

The default is to use no simplification.

Note

This simplification method is only used during non-preview renders.

New in version 3.10.

Return type:

QgsVectorSimplifyMethod

testFlag(self, flag: QgsLayoutRenderContext.Flag) bool

Check whether a particular rendering flag is enabled for the layout.

See also

setFlags()

See also

setFlag()

See also

flags()

Parameters:

flag (QgsLayoutRenderContext.Flag) –

Return type:

bool

textRenderFormat(self) Qgis.TextRenderFormat

Returns the text render format, which dictates how text is rendered (e.g. as paths or real text objects).

New in version 3.4.3.

Return type:

Qgis.TextRenderFormat

timerEvent(self, QTimerEvent)