Como alterar a expressão para definir o número de casas decimais?
layer.dataProvider().addAttributes([QgsField("fieldname", QVariant.Double)])
Como li na documentação da API QGIS:
Parameters
name Field name
type Field variant type, currently supported: String / Int / Double
typeName Field type (eg. char, varchar, text, int, serial, double).
len Field length
prec Field precision
Então eu tento:
layer.dataProvider().addAttributes([QgsField("fieldname", QVariant.Double, 10, 3)])
Mas eu recebo este erro:
TypeError: arguments did not match any overloaded call:
QgsField(QString name=QString(), Type type=QVariant.Invalid, QString
typeName=QString(), int len=0, int prec=0, QString comment=QString()):
argument 3 has unexpected type 'int'
QgsField(QgsField): argument 1 has unexpected type 'str'