Subgroup: Pal

Class: QgsPalLabeling

class qgis.core.QgsPalLabeling

Bases: sip.wrapper

QgsPalLabeling(QgsPalLabeling)

Methods

geometryRequiresPreparation Checks whether a geometry requires preparation before registration with PAL
prepareGeometry Prepares a geometry for registration with PAL.
splitToGraphemes Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string.
splitToLines Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter).
staticWillUseLayer called to find out whether the layer is used for labeling

Signals

Attributes

geometryRequiresPreparation(geometry: QgsGeometry, context: QgsRenderContext, ct: QgsCoordinateTransform, clipGeometry: QgsGeometry = QgsGeometry()) → bool

Checks whether a geometry requires preparation before registration with PAL

Parameters:
  • geometry – geometry to prepare
  • context – render context
  • ct – coordinate transform, or invalid transform if no transformation required
  • clipGeometry – geometry to clip features to, if applicable
Returns:

true if geometry requires preparation

New in version 2.9.

prepareGeometry(geometry: QgsGeometry, context: QgsRenderContext, ct: QgsCoordinateTransform, clipGeometry: QgsGeometry = QgsGeometry()) → QgsGeometry

Prepares a geometry for registration with PAL. Handles reprojection, rotation, clipping, etc.

Parameters:
  • geometry – geometry to prepare
  • context – render context
  • ct – coordinate transform, or invalid transform if no transformation required
  • clipGeometry – geometry to clip features to, if applicable
Returns:

prepared geometry

New in version 2.9.

splitToGraphemes(text: str) → List[str]

Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string. This accounts for scripts were individual characters are not allowed to be split apart (e.g., Arabic and Indic based scripts)

Parameters:text – string to split
Returns:list of graphemes

New in version 2.10.

splitToLines(text: str, wrapCharacter: str, autoWrapLength: int = 0, useMaxLineLengthWhenAutoWrapping: bool = True) → List[str]

Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter). The text string will be split on either newline characters or the wrap character.

Since QGIS 3.4 the autoWrapLength argument can be used to specify an ideal length of line to automatically wrap text to (automatic wrapping is disabled if autoWrapLength is 0). This automatic wrapping is performed after processing wrapping using wrapCharacter. When auto wrapping is enabled, the useMaxLineLengthWhenAutoWrapping argument controls whether the lines should be wrapped to an ideal maximum of autoWrapLength characters, or if false then the lines are wrapped to an ideal minimum length of autoWrapLength characters.

New in version 2.9.

staticWillUseLayer(layer: QgsVectorLayer) → bool

called to find out whether the layer is used for labeling

New in version 2.4.