[Qgis-developer] Custom form init function changes - Kind of API break
Andreas Neumann
a.neumann at carto.net
Tue Jul 10 04:15:03 PDT 2012
Hi Nathan,
This makes sense to me. I will have to adapt my code but it is more
convenient and powerful now.
Thanks a lot,
Andreas
On Tue, 10 Jul 2012 21:07:19 +1000, Nathan Woodrow wrote:
> Hey All,
>
> This is a just a quick email to let everyone know that I have changed
> the way that arguments are passed to a layers Init Python function.
> That is the option that you find in the Layer Properties dialog on
> the
> General tab. If you are using this then this will affect you and you
> will know what I'm talking about.
>
> I have changed it so that the reference to the layer and feature are
> now passed into the function rather then just ids. The issue with
> just passing the feature id was that you couldn't get access to the
> new feature and geometry because you were given a 0 as the id and 0
> is
> a valid id for already existing feature.
>
> So now instead of this:
>
> def myFunction(dialog, layer_id, feature_id)
>
> where layer_id and feature_id are integers. You now do this:
>
> def myFunction(dialog, layer, feature)
>
> layer is a instance of QgsVectorLayer
> feature is a instance of QgsFeature
>
> You can now do things like:
>
> def myFunction(dialog, layer, feature):
> id = layer.id()
> name = layer.name()
> geom = feature.geometry()
> geom.length()
> # etc
>
> This change will break your custom form logic if your code is
> expecting a interger for the feature argument but you get a
> QgsFeature
>
> Just a FYI so you don't freak out when you form logic doesn't work
> anymore.
>
> - Nathan
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
--
Andreas Neumann
Böschacherstrasse 10A
8624 Grüt (Gossau ZH)
Switzerland
More information about the Qgis-developer
mailing list