Hi Calvin On Thu, Jul 6, 2017 at 5:06 PM, C Hamilton <[email protected]> wrote: > Formally I was using the following in my code to add a default label to my > points vector layer: > > label = QgsPalLayerSettings() > label.readFromLayer(ptLayer) > label.enabled = True > label.fieldName = 'label' > label.placement= QgsPalLayerSettings.AroundPoint > label.writeToLayer(ptLayer) > > In looking at the api break documentation readFromLayer and writeToLayer > have been removed and I need to somehow use QgsAbstractVectorLayerLabeling, > but I cannot see what I need to change just to add a label to my point > layer. I am not trying to do anything fancy. All I want is to specify a > field to be used to label the points layer and just use the default styling. > Any help understanding the new API changes would be appreciated.
This should work: settings = QgsPalLayerSettings() settings.fieldName = 'id' labeling = QgsVectorLayerSimpleLabeling(settings) layer.setLabeling(labeling) Please note that it is still too early to port your code to QGIS 3.0 - there may be further API breaks. Here I would say that QgsPalLayerSettings class may be renamed and its API may be updated. Regards Martin _______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
