My goal is to add Callouts (Manhattan type) to labels in a point layer with PyQGIS.
Here is what I got so far, which basically renders the labels without the callouts:
font = QgsTextFormat() font.setFont(QFont('MS Shell Dlg 2')) font.setSize(12) p_layer = QgsPalLayerSettings() p_layer.setFormat(font) p_layer.fieldName = 'label' p_layer.enabled = True labels = QgsVectorLayerSimpleLabeling(p_layer) layer.setLabeling(labels) layer.setLabelsEnabled(True) layer.triggerRepaint()
What I have tried:
When I try to start setting/using the QgsCallout() class, I get the following message in the QGIS Python console:
TypeError: qgis._core.QgsCallout represents a C++ abstract class and cannot be instantiated
According to this answer in StackOverflow:
"The error means there are some methods of the class that aren't implemented. ..."
Question: How to add Callouts to labels with PyQGIS? I'm using QGIS version 3.14.1