[QGIS-Developer] Python question: QgsVectorLayer object has no attribute 'pendingFields'

Alessandro Pasotti apasotti at gmail.com
Mon Jan 15 09:13:12 PST 2018


On Mon, Jan 15, 2018 at 6:10 PM, Andreas Neumann <a.neumann at carto.net>
wrote:

> Hi,
>
> I am trying to fix some Python code that worked before, but not anymore
> due to API changes in master meanwhile.
>
> I am getting a reference to a layer by name and then want to query the
> 'pendingFields'. Here is the code I use:
>
> ---------------------
>
> LayerParcels= QgsProject.instance().layerStore().mapLayersByName('
> Parcels')[0]
>
> newParcel = QgsFeature()
>
> newParcel .setFields(LayerParcels.pendingFields())
>
> -------------------------
>
> The first two lines seem to work, but the third line triggers an error:
>
> AttributeError: 'QgsVectorLayer' object has no attribute 'pendingFields'
>
> Why is that?
>
> This code worked a few weeks before and the 'pendingFields' - according to
> https://qgis.org/api/classQgsVectorLayer.html still exists?
>
> What is wrong with my code?
>
> Thanks for any hints!
>
> Andreas
>

Hi Andreas, I believe you should just use  LayerParcels.fields()
pendingFields is gone.


-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180115/1b40ba3f/attachment-0001.html>


More information about the QGIS-Developer mailing list