I would like to create a new virtual field with a specific expression (like 2*"ID") on an existing layer. Is it possible to do so from the Python console?
I've tried using addExpressionField
followed by updatefields
as suggested in a similar question (Creating Virtual Field in QGIS Python Console) but when I manually check my layer fields from QGIS, nothing changed.
Best Answer
Try to get the
addExpressionField()
method from theQgsVectorLayer
class with this:References: