Hi devs,

I'm struggling with a maybe simple issue..

In a plugin I have added a QgsFieldExpressionWidget connected to a QgsMapLayerComboBox..

What I am currently trying to do without any result is to get a list of the field values filtered with the result of the expression added

In a *normal* QgsFieldComboBox I achive it as follows:

# QgsMapLayerComboBox
lay1 = self.Field1.layer()
# QgsFieldComboBox
lay1_f = self.Field1.currentField()


# create the list of the selected fields
f1 = []
    for i in lay1.getFeatures():
    f1.append(i[lay1_f])


so f1 is a list of the selected filed..

In the API I saw that QgsFieldExpressionWidget returns a tuple (Expression text, if expression is used, is expression is valid)..

the expression text is accessible with the currentText() method.. but if I add an expression the above method doesn't work (e.g. if I try to divide by 10 the field AAA:

KeyError
'AAA / 10'

so I'm not able to combine the expression added as filter for the field

Someone has any suggestions?

Thanks in advance

Cheers

Matteo
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to