Subgroup: Rule

Class: QgsRuleBasedLabeling

class qgis.core.QgsRuleBasedLabeling(root: QgsRuleBasedLabeling.Rule)

Bases: qgis._core.QgsAbstractVectorLayerLabeling

Constructs the labeling from given tree of rules (takes ownership)

New in version 3.0: Methods

clone
create Create the instance from a DOM element with saved configuration
requiresAdvancedEffects
rootRule
save
setSettings Set pal settings for a specific provider (takes ownership).
settings
subProviders
toSld
type
writeTextSymbolizer

Signals

Attributes

class Rule(settings: QgsPalLayerSettings, maximumScale: int = 0, minimumScale: int = 0, filterExp: str = '', description: str = '', elseRule: bool = False)

Bases: sip.wrapper

takes ownership of settings

New in version 3.0.

Filtered = 0
Inactive = 1
class RegisterResult

Bases: int

Registered = 2
active(self) → bool

Returns if this rule is active

Returns:True if the rule is active
appendChild(self, rule: QgsRuleBasedLabeling.Rule)

add child rule, take ownership, sets this as parent

children(self) → object

Return all children rules of this rule

Returns:A list of rules
clone(self) → QgsRuleBasedLabeling.Rule

clone this rule, return new instance

create(ruleElem: QDomElement, context: QgsReadWriteContext) → QgsRuleBasedLabeling.Rule

Create a rule from an XML definition

Parameters:
  • ruleElem – The XML rule element
  • context – reading context
Returns:

A new rule

dependsOnScale(self) → bool

Determines if scale based labeling is active

Returns:True if scale based labeling is active
descendants(self) → object

Returns all children, grand-children, grand-grand-children, grand-gra… you get it

Returns:A list of descendant rules
description(self) → str

A human readable description for this rule

Returns:Description
filterExpression(self) → str

A filter that will check if this rule applies

Returns:An expression
findRuleByKey(self, key: str) → QgsRuleBasedLabeling.Rule

Try to find a rule given its unique key

insertChild(self, i: int, rule: QgsRuleBasedLabeling.Rule)

add child rule, take ownership, sets this as parent

isElse(self) → bool

Check if this rule is an ELSE rule

Returns:True if this rule is an else rule
maximumScale(self) → float

Returns the maximum map scale (i.e. most “zoomed in” scale) at which the label rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.

See also

minimumScale()

New in version 3.0.

minimumScale(self) → float

Returns the minimum map scale (i.e. most “zoomed out” scale) at which the label rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.

See also

maximumScale()

New in version 3.0.

parent(self) → QgsRuleBasedLabeling.Rule

The parent rule

Returns:Parent rule
removeChildAt(self, i: int)

delete child rule

requiresAdvancedEffects(self) → bool

Returns true if this rule or any of its children requires advanced composition effects to render.

ruleKey(self) → str

Unique rule identifier (for identification of rule within labeling, used as provider ID)

save(self, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement

store labeling info to XML element

setActive(self, state: bool)

Sets if this rule is active

Parameters:state – Determines if the rule should be activated or deactivated
setDescription(self, description: str)

Set a human readable description for this rule

Parameters:description – Description
setFilterExpression(self, filterExp: str)

Set the expression used to check if a given feature shall be rendered with this rule

Parameters:filterExp – An expression
setIsElse(self, iselse: bool)

Sets if this rule is an ELSE rule

Parameters:iselse – If true, this rule is an ELSE rule
setMaximumScale(self, scale: float)

Sets the maximum map scale (i.e. most “zoomed in” scale) at which the rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.

See also

maximumScale()

setMinimumScale(self, scale: float)

Sets the minimum map scale (i.e. most “zoomed out” scale) at which the label rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.

See also

minimumScale()

setRuleKey(self, key: str)

Override the assigned rule key (should be used just internally by rule-based labeling)

setSettings(self, settings: QgsPalLayerSettings)

set new settings (or NULL). Deletes old settings if any.

settings(self) → QgsPalLayerSettings

Get the labeling settings. May return a null pointer.

clone(self) → QgsRuleBasedLabeling
create(element: QDomElement, context: QgsReadWriteContext) → QgsRuleBasedLabeling

Create the instance from a DOM element with saved configuration

requiresAdvancedEffects(self) → bool
rootRule(self) → QgsRuleBasedLabeling.Rule
save(self, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement
setSettings(self, settings: QgsPalLayerSettings, providerId: str = '')

Set pal settings for a specific provider (takes ownership).

Parameters:
  • settings – Pal layer settings
  • providerId – The id of the provider

New in version 3.0.

settings(self, providerId: str = '') → QgsPalLayerSettings
subProviders(self) → List[str]
toSld(self, parent: QDomNode, props: Dict[str, str])
type(self) → str
writeTextSymbolizer()