Class: QgsLayoutItemPicture

class qgis.core.QgsLayoutItemPicture(layout: QgsLayout)

Bases: qgis._core.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: Enums

Methods

adjustPointForReferencePosition

applyDataDefinedSize

applyItemSizeConstraint

childEvent

connectNotify

contextMenuEvent

create

Returns a new picture item for the specified layout.

customEvent

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

draw

drawBackground

drawDebugRect

drawFrame

dropEvent

evaluatedPath

Returns the current evaluated picture path, which includes the result of data defined path overrides.

finalizeRestoreFromXml

focusInEvent

focusOutEvent

hoverEnterEvent

hoverLeaveEvent

hoverMoveEvent

icon

inputMethodEvent

inputMethodQuery

isMissingImage

Returns True if the source image is missing and the picture cannot be rendered.

isSignalConnected

itemChange

keyPressEvent

keyReleaseEvent

linkedMap

Returns the linked rotation map, if set.

mode

Returns the current picture mode (image format).

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

northMode

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

northOffset

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

pictureAnchor

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

picturePath

Returns the path of the source image.

pictureRotation

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

positionAtReferencePoint

prepareGeometryChange

readObjectPropertiesFromElement

readPropertiesFromElement

recalculateSize

Forces a recalculation of the picture’s frame size

receivers

refreshBackgroundColor

refreshBlendMode

refreshDataDefinedProperty

refreshFrame

refreshItemPosition

refreshItemRotation

refreshItemSize

refreshOpacity

refreshPicture

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

resizeMode

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

sceneEvent

sceneEventFilter

sender

senderSignalIndex

setFixedSize

setLinkedMap

Sets the map object for rotation.

setMinimumSize

setNorthMode

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

setNorthOffset

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

setPictureAnchor

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

setPicturePath

Sets the source path of the image (may be svg or a raster format).

setPictureRotation

Sets the picture rotation within the item bounds, in degrees clockwise.

setResizeMode

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

setSvgFillColor

Sets the fill color used for parametrized SVG files.

setSvgStrokeColor

Sets the stroke color used for parametrized SVG files.

setSvgStrokeWidth

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

svgFillColor

Returns the fill color used for parametrized SVG files.

svgStrokeColor

Returns the stroke color used for parametrized SVG files.

svgStrokeWidth

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

timerEvent

topLeftToReferencePoint

type

updateMicroFocus

wheelEvent

writeObjectPropertiesToElement

writePropertiesToElement

Signals

pictureRotationChanged

Emitted on picture rotation change [signal]

Attributes

Clip

FormatRaster

FormatSVG

FormatUnknown

FrameToImageSize

GridNorth

Stretch

TrueNorth

Zoom

ZoomResizeFrame

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

customEvent()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
draw(self, context: QgsLayoutItemRenderContext)
drawBackground()
drawDebugRect()
drawFrame()
dropEvent()
evaluatedPath(self) → str

Returns the current evaluated picture path, which includes the result of data defined path overrides.

See also

picturePath()

New in version 3.6.

finalizeRestoreFromXml(self)
focusInEvent()
focusOutEvent()
hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
icon(self) → QIcon
inputMethodEvent()
inputMethodQuery()
isMissingImage(self) → bool

Returns True if the source image is missing and the picture cannot be rendered.

New in version 3.6.

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

mode(self) → QgsLayoutItemPicture.Format

Returns the current picture mode (image 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()

northOffset(self) → float

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

See also

setNorthOffset()

See also

northMode()

pictureAnchor(self) → QgsLayoutItem.ReferencePoint

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

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.

Returns

path for the source image

See also

setPicturePath()

See also

evaluatedPath()

pictureRotation(self) → float

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

See also

linkedMap()

pictureRotationChanged

Emitted on picture rotation change [signal]

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

Forces a recalculation of the picture’s frame size

receivers()
refreshBackgroundColor()
refreshBlendMode()
refreshDataDefinedProperty(self, 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 – 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()

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

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

setNorthOffset(self, offset: float)

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

See also

northOffset()

See also

setNorthMode()

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

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

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.

setResizeMode(self, mode: QgsLayoutItemPicture.ResizeMode)

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

Parameters

mode – 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()

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

Sets the stroke color used for parametrized SVG files.

Parameters

color – 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()

svgFillColor(self) → QColor

Returns the fill color used for parametrized SVG files.

See also

svgStrokeColor()

svgStrokeColor(self) → QColor

Returns the stroke color used for parametrized SVG files.

See also

svgFillColor()

svgStrokeWidth(self) → float

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

See also

svgStrokeColor()

timerEvent()
topLeftToReferencePoint()
type(self) → int
updateMicroFocus()
wheelEvent()
writeObjectPropertiesToElement()
writePropertiesToElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool