Class: QgsEffectStack

A paint effect which consists of a stack of other chained paint effects.

Effect stacks can be used to apply multiple paint effects to a QPicture. For instance, an effect stack may blur then apply a drop shadow.

The way in which effects apply to a stack is controlled by the effect’s drawMode. Effects can either render their results onto the destination paint device, or just modify the source picture which is drawn by subsequent effects in the stack. For instance, a blur effect with a Modifier drawMode will blur the source picture for the following drop shadow effect without actually drawing the blurred picture to the paint device. If the blur effect had a Render drawMode then the blurred picture will be drawn on the paint device, but the following drop shadow effect will be drawn using the original picture, not the blurred version.

Class Hierarchy

Inheritance diagram of qgis.core.QgsEffectStack

Base classes

QgsPaintEffect

Base class for visual effects which can be applied to QPicture drawings.

Abstract Methods

properties

Unused for QgsEffectStack, will always return an empty string map

readProperties

Methods

appendEffect

Appends an effect to the end of the stack.

changeEffect

Replaces the effect at a specified position within the stack.

count

Returns count of effects contained by the stack

effect

Returns a pointer to the effect at a specified index within the stack

effectList

Returns a pointer to the list of effects currently contained by the stack

insertEffect

Inserts an effect at a specified index within the stack.

takeEffect

Removes an effect from the stack and returns a pointer to it.

Static Methods

create

Creates a new QgsEffectStack effect.

class qgis.core.QgsEffectStack[source]

Bases: QgsPaintEffect

__init__()
__init__(other: QgsEffectStack)
Parameters:

other (QgsEffectStack)

__init__(effect: QgsPaintEffect)

Creates a new QgsEffectStack effect from a single initial effect.

Parameters:

effect (QgsPaintEffect) – initial effect to add to the stack. The effect will be cloned, so ownership is not transferred to the stack.

appendEffect(self, effect: QgsPaintEffect | None)[source]

Appends an effect to the end of the stack.

Parameters:

effect (Optional[QgsPaintEffect]) – QgsPaintEffect to append. Ownership of the effect will be transferred to the stack object.

See also

insertEffect()

changeEffect(self, index: int, effect: QgsPaintEffect | None) bool[source]

Replaces the effect at a specified position within the stack.

Parameters:
  • index (int) – position of effect to replace

  • effect (Optional[QgsPaintEffect]) – QgsPaintEffect to replace with. Ownership of the effect will be transferred to the stack object.

Return type:

bool

count(self) int[source]

Returns count of effects contained by the stack

Return type:

int

Returns:

count of effects

static create(map: Dict[str, Any]) QgsPaintEffect | None[source]

Creates a new QgsEffectStack effect. This method ignores the map parameter, and always returns an empty effect stack.

Parameters:

map (Dict[str, Any]) – unused encoded properties string map

Return type:

Optional[QgsPaintEffect]

Returns:

new QgsEffectStack

effect(self, index: int) QgsPaintEffect | None[source]

Returns a pointer to the effect at a specified index within the stack

Parameters:

index (int) – position of effect to return

Return type:

Optional[QgsPaintEffect]

Returns:

QgsPaintEffect at specified position

effectList(self) List[QgsPaintEffect] | None

Returns a pointer to the list of effects currently contained by the stack

Return type:

Optional[List[QgsPaintEffect]]

Returns:

list of QgsPaintEffects within the stack

insertEffect(self, index: int, effect: QgsPaintEffect | None) bool[source]

Inserts an effect at a specified index within the stack.

Parameters:
  • index (int) – position to insert the effect

  • effect (Optional[QgsPaintEffect]) – QgsPaintEffect to insert. Ownership of the effect will be transferred to the stack object.

See also

appendEffect()

Return type:

bool

abstract properties(self) Dict[str, Any][source]

Unused for QgsEffectStack, will always return an empty string map

Return type:

Dict[str, Any]

abstract readProperties(self, element: QDomElement) bool[source]
Parameters:

element (QDomElement)

Return type:

bool

abstract readProperties(self, props: Dict[str, Any])[source]

Unused for QgsEffectStack, props parameter will be ignored

Parameters:

props (Dict[str, Any])

takeEffect(self, index: int) QgsPaintEffect | None[source]

Removes an effect from the stack and returns a pointer to it.

Parameters:

index (int) – position of effect to take

Return type:

Optional[QgsPaintEffect]