On Tue, 21 May 2019 at 05:53, Anita Graser <[email protected]> wrote:
>
> Dear Nyall,
>
> for f in vl.getFeatures():
>     scope[-1].setFeature(f)

This works, but isn't very nice. Better to use

    context.setFeature(f)

(behind the scenes it's doing the same, but is more descriptive and
has some extra checks, e.g. starting with an empty context:
    context = QgsExpressionContext()
    context.setFeature(f)
will automatically add an initial scope in which to set the feature)

> scope = QgsExpressionContextUtils.globalProjectLayerScopes(vl)

Being pedantic, this should be "scopes = ...", since the call returns
a list of scopes.

Nyall
_______________________________________________
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

Reply via email to