Hi Alexandre,

I recently used provider default values in a plugin like this..

provider = layer.dataProvider()
        f = QgsFeature()
        
        #On the Fly reprojection.
        if layerCRSSrsid != projectCRSSrsid:
            geom.transform(QgsCoordinateTransform(projectCRSSrsid,
layerCRSSrsid))
                                    
        f.setGeometry(geom)
        
        # add attribute fields to feature
        fields = layer.pendingFields()

        # vector api change update
        if QGis.QGIS_VERSION_INT >= 10900:
            f.initAttributes(fields.count())                    
            for i in range(fields.count()):
                f.setAttribute(i,provider.defaultValue(i))
        else:
            for i in fields:
                f.addAttribute(i,  provider.defaultValue(i))



--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/How-to-get-Provider-default-values-for-each-attribute-using-Python-tp5032168p5032343.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to