Im using QGIS 3.18.2 and I want to get the expression string of a virtual field in
QgsVectorLayer.expressionField() is supposed to return the expression string. It takes the index (
index: int) of the expression (virtual) field as argument.
Let's say I have a virtual field named
expr_f_1. When I call
QgsVectorDataProvider.fieldNameIndex("expr_f_1") it returns
-1, which corresponds to a missing field. This seems to happen for virtual fields in general.
They also don't appear in
How do I get the correct index of a virtual field, in order to pass it to
QgsVectorLayer.expressionField() to return the corresponding expression string?