Class: QgsLayoutItemPicture

class qgis.core.QgsLayoutItemPicture(layout: QgsLayout)

Bases: QgsLayoutItem

Constructor for QgsLayoutItemPicture, with the specified parent layout.

A layout item subclass that displays SVG files or raster format images (jpg, png, …).

New in version 3.0.

Parameters

layout

Clip = 2
class Format

Bases: int

FormatRaster = 1
FormatSVG = 0
FormatUnknown = 2
FrameToImageSize = 4
GridNorth = 0
class NorthMode

Bases: int

class ResizeMode

Bases: int

Stretch = 1
TrueNorth = 1
Zoom = 0
ZoomResizeFrame = 3
adjustPointForReferencePosition()
applyDataDefinedSize()
applyItemSizeConstraint(self, targetSize: QSizeF) → QSizeF
Parameters

targetSize (QSizeF) –

Return type

QSizeF

childEvent()
connectNotify()
contextMenuEvent()
create(layout: QgsLayout) → QgsLayoutItemPicture

Returns a new picture item for the specified layout.

The caller takes responsibility for deleting the returned object.

Parameters

layout (QgsLayout) –

Return type

QgsLayoutItemPicture

customEvent()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
draw(self, context: QgsLayoutItemRenderContext)
Parameters

context (QgsLayoutItemRenderContext) –

drawBackground()
drawDebugRect()
drawFrame()
dropEvent()
finalizeRestoreFromXml(self)
focusInEvent()
focusOutEvent()
hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
icon(self) → QIcon
Return type

QIcon

inputMethodEvent()
inputMethodQuery()
isSignalConnected()
itemChange()
keyPressEvent()
keyReleaseEvent()
linkedMap(self) → QgsLayoutItemMap

Returns the linked rotation map, if set. An None means map rotation is disabled. If this is set then the picture is rotated by the same amount as the specified map object.

See also

setLinkedMap()

Return type

QgsLayoutItemMap

mode(self) → QgsLayoutItemPicture.Format

Returns the current picture mode (image format).

Return type

QgsLayoutItemPicture.Format

mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
northMode(self) → QgsLayoutItemPicture.NorthMode

Returns the mode used to align the picture to a map’s North.

See also

setNorthMode()

See also

northOffset()

Return type

QgsLayoutItemPicture.NorthMode

northOffset(self) → float

Returns the offset added to the picture’s rotation from a map’s North.

See also

setNorthOffset()

See also

northMode()

Return type

float

pictureAnchor(self) → QgsLayoutItem.ReferencePoint

Returns the picture’s current anchor, which controls how it is placed within the picture item’s frame.

Return type

QgsLayoutItem.ReferencePoint

picturePath(self) → str

Returns the path of the source image. Data defined picture source may override this value. The path can either be a local path or a remote (http) path.

Return type

str

Returns

path for the source image

See also

setPicturePath()

pictureRotation(self) → float

Returns the rotation used for drawing the picture within the item’s frame, in degrees clockwise.

See also

linkedMap()

Return type

float

pictureRotationChanged

Is emitted on picture rotation change [signal]

positionAtReferencePoint()
prepareGeometryChange()
readObjectPropertiesFromElement()
readPropertiesFromElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
Parameters
Return type

bool

recalculateSize(self)

Forces a recalculation of the picture’s frame size

receivers()
refreshBackgroundColor()
refreshBlendMode()
refreshDataDefinedProperty(self, property: QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties)
Parameters

property (QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties) –

refreshFrame()
refreshItemPosition()
refreshItemRotation()
refreshItemSize()
refreshOpacity()
refreshPicture(self, context: QgsExpressionContext = None)

Recalculates the source image (if using an expression for picture’s source) and reloads and redraws the picture.

Parameters

context (QgsExpressionContext = None) – expression context for evaluating data defined picture sources

resizeMode(self) → QgsLayoutItemPicture.ResizeMode

Returns the resize mode used for drawing the picture within the composer item’s frame.

See also

setResizeMode()

Return type

QgsLayoutItemPicture.ResizeMode

sceneEvent()
sceneEventFilter()
sender()
senderSignalIndex()
setFixedSize()
setLinkedMap(self, map: QgsLayoutItemMap)

Sets the map object for rotation.

If this is set then the picture will be rotated by the same amount as the specified map object. This is useful especially for syncing north arrows with a map item.

See also

linkedMap()

Parameters

map (QgsLayoutItemMap) –

setMinimumSize()
setNorthMode(self, mode: QgsLayoutItemPicture.NorthMode)

Sets the mode used to align the picture to a map’s North.

See also

northMode()

See also

setNorthOffset()

Parameters

mode (QgsLayoutItemPicture.NorthMode) –

setNorthOffset(self, offset: float)

Sets the offset added to the picture’s rotation from a map’s North.

See also

northOffset()

See also

setNorthMode()

Parameters

offset (float) –

setPictureAnchor(self, anchor: QgsLayoutItem.ReferencePoint)

Sets the picture’s anchor point, which controls how it is placed within the picture item’s frame.

See also

pictureAnchor()

Parameters

anchor (QgsLayoutItem.ReferencePoint) –

setPicturePath(self, path: str)

Sets the source path of the image (may be svg or a raster format). Data defined picture source may override this value. The path can either be a local path or a remote (http) path.

See also

picturePath()

Parameters

path (str) –

setPictureRotation(self, rotation: float)

Sets the picture rotation within the item bounds, in degrees clockwise. This does not affect the item’s frame, only the way the picture is drawn within the item.

Parameters

rotation (float) –

setResizeMode(self, mode: QgsLayoutItemPicture.ResizeMode)

Sets the resize mode used for drawing the picture within the item bounds.

Parameters

mode (QgsLayoutItemPicture.ResizeMode) – ResizeMode to use for image file

See also

resizeMode()

setSvgFillColor(self, color: Union[QColor, Qt.GlobalColor])

Sets the fill color used for parametrized SVG files.

Note

This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.

See also

svgFillColor()

Parameters

color (Union[QColor) –

setSvgStrokeColor(self, color: Union[QColor, Qt.GlobalColor])

Sets the stroke color used for parametrized SVG files.

Parameters

color (Union[QColor) – stroke color.

Note

This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.

See also

svgStrokeColor()

setSvgStrokeWidth(self, width: float)

Sets the stroke width (in layout units) used for parametrized SVG files.

Note

This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.

See also

svgStrokeWidth()

Parameters

width (float) –

svgFillColor(self) → QColor

Returns the fill color used for parametrized SVG files.

See also

svgStrokeColor()

Return type

QColor

svgStrokeColor(self) → QColor

Returns the stroke color used for parametrized SVG files.

See also

svgFillColor()

Return type

QColor

svgStrokeWidth(self) → float

Returns the stroke width (in layout units) used for parametrized SVG files.

See also

svgStrokeColor()

Return type

float

timerEvent()
topLeftToReferencePoint()
type(self) → int
Return type

int

updateMicroFocus()
wheelEvent()
writeObjectPropertiesToElement()
writePropertiesToElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
Parameters
Return type

bool