Class: QgsLabelingResults

Stores computed placement from labeling engine.

List of all members, including inherited members

Constructor

__init__

Methods

allLabels

Returns a list of all labels generated by the labeling run.

calloutsWithinRectangle

Returns a list of callouts with origins or destinations inside the given rectangle.

groupedLabelPositions

Returns a list of all label positions sharing the same group ID (i.e. positions for individual characters in a curved label).

hasSearchTree

Returns True if the results were constructed with search tree enabled.

labelsAtPosition

Returns the details of any labels placed at the specified point (in map coordinates).

labelsWithinRect

Returns the details of any labels placed within the specified rectangle (in map coordinates).

setMapSettings

Sets the map settings associated with the labeling run.

class qgis.core.QgsLabelingResults[source]

Bases: object

__init__(enableSearchTree: bool = True)

Constructor for QgsLabelingResults.

Parameters:

enableSearchTree (bool = True) – set to False to disable the search tree. This can be used to speed up labeling in cases where spatial querying of labels is not required (since QGIS 4.4)

allLabels(self) list[QgsLabelPosition]

Returns a list of all labels generated by the labeling run.

Added in version 3.20.

Return type:

list[QgsLabelPosition]

calloutsWithinRectangle(self, rectangle: QgsRectangle) list[QgsCalloutPosition]

Returns a list of callouts with origins or destinations inside the given rectangle.

The rectangle is specified in map coordinates.

Note

Only available when hasSearchTree() is True.

Added in version 3.20.

Parameters:

rectangle (QgsRectangle)

Return type:

list[QgsCalloutPosition]

groupedLabelPositions(self, groupId: int) list[QgsLabelPosition]

Returns a list of all label positions sharing the same group ID (i.e. positions for individual characters in a curved label).

Note

Only available when hasSearchTree() is True.

Added in version 3.26.

Parameters:

groupId (int)

Return type:

list[QgsLabelPosition]

hasSearchTree(self) bool[source]

Returns True if the results were constructed with search tree enabled.

If the search tree is not available, then spatial querying based methods like labelsAtPosition() will not be available.

Added in version 4.4.

Return type:

bool

labelsAtPosition(self, p: QgsPointXY) list[QgsLabelPosition]

Returns the details of any labels placed at the specified point (in map coordinates).

Note

Only available when hasSearchTree() is True.

Parameters:

p (QgsPointXY)

Return type:

list[QgsLabelPosition]

labelsWithinRect(self, r: QgsRectangle) list[QgsLabelPosition]

Returns the details of any labels placed within the specified rectangle (in map coordinates).

Note

Only available when hasSearchTree() is True.

Parameters:

r (QgsRectangle)

Return type:

list[QgsLabelPosition]

setMapSettings(self, settings: QgsMapSettings)[source]

Sets the map settings associated with the labeling run.

Added in version 3.4.8.

Parameters:

settings (QgsMapSettings)