In the Memory provider described in PyQGIS Cookbook or in question How to create a new empty vector layer programmatically? I can see how to create a vector layer programmatically using standard fields (String, Int, Double).
with PyQGIS/QGIS 1.8.0, is it possible to programmatically add calculated fields like the ones defined using the GUI field calculator? After some reading about QgsExpression I'm thinking in something like this:
exp = QgsExpression('Column * 3') pr.addAttributes( [ QgsField( "fieldName", QVariant.Expression, exp ) ] )