[QGIS-Developer] Get data from QgsFieldExpressionWidget (QGIS Master)
Nyall Dawson
nyall.dawson at gmail.com
Mon Jun 26 15:32:18 PDT 2017
On 26 June 2017 at 21:11, matteo <matteo.ghetta at gmail.com> wrote:
> Hi all,
>
> I'm writing a plugin that uses QgsFieldExpressionWidget to get the field
> and its attributes from a layer.
>
> I'm really fighting to find a method to get the attributes of the field
> as a list when an expression if typed.
In QGIS 3.0 QgsVectorLayer::getValues will do what you want in a single call:
https://qgis.org/api/classQgsVectorLayer.html#ac8cfb12633ed536da73f42ebff095f99
That works for either a field:
layer.getValues('my_field')
or an expression:
layer.getValues('my_field * 2')
Nyall
More information about the QGIS-Developer
mailing list