Class: QgsPictureRasterizer

Rasterizes and caches a QPicture as a QImage at a requested size.

Allows for background asynchronous regeneration of the cached image at a different size.

This class is useful for generating pre-rendered versions of QPictures for rendering on the main GUI thread, where those pictures are too expensive to draw directly.

Added in version 4.4.

List of all members, including inherited members

Class Hierarchy

Inheritance diagram of qgis.core.QgsPictureRasterizer

Base classes

QObject

Constructor

__init__

Methods

clear

Clears the source picture and cached image, canceling any in-progress background render.

image

Immediately returns the best available QImage for the given targetSize.

invalidate

Immediately invalidates the current cached image.

isRendering

Returns True if a background job is currently running or scheduled.

maxCacheSize

Returns the maximum width or height (in pixels) of the cached QImage.

picture

Returns the current source QPicture.

setMaxCacheSize

Sets the maximum width or height (in pixels) of the cached QImage.

setPicture

Sets the source picture to cache.

Signals

rendered

Emitted when a background rasterization finishes and a new cached image is available.

class qgis.core.QgsPictureRasterizer[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsPictureRasterizer, with the specified parent object.

Parameters:

parent (QObject|None = None)

clear(self)[source]

Clears the source picture and cached image, canceling any in-progress background render.

image(self, targetSize: QSize) → QImage[source]

Immediately returns the best available QImage for the given targetSize.

This method never blocks. If no cached image exists for the specified targetSize or the cache has been invalidated then the previously cached image is returned, and a background render at the desired targetSize will be started.

Parameters:

targetSize (QSize)

Return type:

QImage

invalidate(self)[source]

Immediately invalidates the current cached image.

isRendering(self) → bool[source]

Returns True if a background job is currently running or scheduled.

Return type:

bool

maxCacheSize(self) → int[source]

Returns the maximum width or height (in pixels) of the cached QImage.

Return type:

int

picture(self) → QPicture[source]

Returns the current source QPicture.

See also

setPicture()

Return type:

QPicture

signal rendered[source]

Emitted when a background rasterization finishes and a new cached image is available.

setMaxCacheSize(self, maxSize: int)[source]

Sets the maximum width or height (in pixels) of the cached QImage.

See also

maxCacheSize()

Parameters:

maxSize (int)

setPicture(self, picture: QPicture)[source]

Sets the source picture to cache.

See also

picture()

Parameters:

picture (QPicture)