Class: QgsLayoutItemPicture¶
A layout item subclass that displays SVG files or raster format images (jpg, png, …).
Class Hierarchy¶
Base classes¶
Base class for graphical items within a |
|
A base class for objects which belong to a layout. |
|
Abstract interface for generating an expression context. |
|
Interface for layout objects which support undo/redo commands. |
- class qgis.core.QgsLayoutItemPicture[source]¶
Bases:
QgsLayoutItem- __init__(layout: QgsLayout | None)
Constructor for QgsLayoutItemPicture, with the specified parent
layout.- Parameters:
layout (Optional[QgsLayout])
- Clip = 2¶
- Format¶
alias of
PictureFormat
- FrameToImageSize = 4¶
- GridNorth = 0¶
- class NorthMode¶
Bases:
int
- class ResizeMode¶
Bases:
int
- Stretch = 1¶
- TrueNorth = 1¶
- Zoom = 0¶
- ZoomResizeFrame = 3¶
- static create(layout: QgsLayout | None) QgsLayoutItemPicture | None[source]¶
Returns a new picture item for the specified
layout.The caller takes responsibility for deleting the returned object.
- Parameters:
layout (Optional[QgsLayout])
- Return type:
Optional[QgsLayoutItemPicture]
- evaluatedPath(self) str[source]¶
Returns the current evaluated picture path, which includes the result of data defined path overrides.
See also
Added in version 3.6.
- Return type:
str
- isMissingImage(self) bool[source]¶
Returns
Trueif the source image is missing and the picture cannot be rendered.Added in version 3.6.
- Return type:
bool
- linkedMap(self) QgsLayoutItemMap | None[source]¶
Returns the linked rotation map, if set. An
Nonemeans map rotation is disabled. If this is set then the picture is rotated by the same amount as the specified map object.See also
- Return type:
Optional[QgsLayoutItemMap]
- mode(self) Qgis.PictureFormat[source]¶
Returns the current picture mode (image format), FormatUnknown if given picture format is unknown
See also
See also
- Return type:
- northMode(self) QgsLayoutItemPicture.NorthMode[source]¶
Returns the mode used to align the picture to a map’s North.
See also
See also
- Return type:
- northOffset(self) float[source]¶
Returns the offset added to the picture’s rotation from a map’s North.
See also
See also
- Return type:
float
- originalMode(self) Qgis.PictureFormat[source]¶
Returns the original set picture mode (image format). It could differ from
mode()if given picture format is unknownSee also
See also
Added in version 3.22.
- Return type:
- pictureAnchor(self) QgsLayoutItem.ReferencePoint[source]¶
Returns the picture’s current anchor, which controls how it is placed within the picture item’s frame.
See also
- Return type:
- picturePath(self) str[source]¶
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
See also
- pictureRotation(self) float[source]¶
Returns the rotation used for drawing the picture within the item’s frame, in degrees clockwise.
See also
See also
- Return type:
float
- signal pictureRotationChanged[source]¶
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.
- refreshPicture(self, context: QgsExpressionContext | None = None)[source]¶
Recalculates the source image (if using an expression for picture’s source) and reloads and redraws the picture.
- Parameters:
context (Optional[QgsExpressionContext] = None) – expression context for evaluating data defined picture sources
- resizeMode(self) QgsLayoutItemPicture.ResizeMode[source]¶
Returns the resize mode used for drawing the picture within the layout item’s frame.
See also
- Return type:
- setLinkedMap(self, map: QgsLayoutItemMap | None)[source]¶
Sets the
mapobject 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
See also
- Parameters:
map (Optional[QgsLayoutItemMap])
- setMode(self, mode: Qgis.PictureFormat)[source]¶
Sets the current picture
mode(image format).See also
Added in version 3.14.
- Parameters:
mode (Qgis.PictureFormat)
- setNorthMode(self, mode: QgsLayoutItemPicture.NorthMode)[source]¶
Sets the
modeused to align the picture to a map’s North.See also
See also
- Parameters:
- setNorthOffset(self, offset: float)[source]¶
Sets the
offsetadded to the picture’s rotation from a map’s North.See also
See also
- Parameters:
offset (float)
- setPictureAnchor(self, anchor: QgsLayoutItem.ReferencePoint)[source]¶
Sets the picture’s
anchorpoint, which controls how it is placed within the picture item’s frame.See also
- Parameters:
anchor (QgsLayoutItem.ReferencePoint)
- setPicturePath(self, path: str | None, format: Qgis.PictureFormat = Qgis.PictureFormat.Unknown)[source]¶
Sets the source
pathof 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.Ideally, the
formatargument should specify the image format.See also
- Parameters:
path (Optional[str])
format (Qgis.PictureFormat = Qgis.PictureFormat.Unknown)
- setPictureRotation(self, rotation: float)[source]¶
Sets the picture
rotationwithin the item bounds, in degrees clockwise. This does not affect the item’s frame, only the way the picture is drawn within the item.See also
- Parameters:
rotation (float)
- setResizeMode(self, mode: QgsLayoutItemPicture.ResizeMode)[source]¶
Sets the resize
modeused for drawing the picture within the item bounds.- Parameters:
mode (QgsLayoutItemPicture.ResizeMode) – ResizeMode to use for image file
See also
- setSvgDynamicParameters(self, parameters: Dict[str | None, QgsProperty])[source]¶
Sets the SVG dynamic parameters
Added in version 3.20.
- Parameters:
parameters (Dict[Optional[str], QgsProperty])
- setSvgFillColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the fill
colorused 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
See also
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setSvgStrokeColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the stroke
colorused for parametrized SVG files.- Parameters:
color (Union[QColor, Qt.GlobalColor]) – stroke color.
Note
This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.
See also
See also
- setSvgStrokeWidth(self, width: float)[source]¶
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
See also
- Parameters:
width (float)
- svgDynamicParameters(self) Dict[str, QgsProperty]¶
Returns the SVG dynamic parameters
Added in version 3.20.
- Return type:
Dict[str, QgsProperty]
- svgFillColor(self) QColor[source]¶
Returns the fill color used for parametrized SVG files.
See also
See also
- Return type:
QColor
- svgStrokeColor(self) QColor[source]¶
Returns the stroke color used for parametrized SVG files.
See also
See also
- Return type:
QColor