Skip to main content
added 27 characters in body
Source Link
Ash
  • 1.3k
  • 7
  • 22

according to @Joseph's answer, if you want to populate your combobox with fields of vector layers, since raster layers does not have any fields of attribute you may get the error: QgsRasterLayerAttributeError: have'QgsRasterLayer' object has no attribute Fields'fields'.

so for avoiding that you must equal your Layers with Only vector layers, like this:

layers = [layer for layer in iface.legendInterface().layers() if layer.type() == QgsMapLayer.VectorLayer]

instead of:

layers = iface.legendInterface().layers() 

good luck...

according to @Joseph's answer, if you want to populate your combobox with fields of vector layers, since raster layers does not have any fields of attribute you may get the error QgsRasterLayer have no attribute Fields.

so for avoiding that you must equal your Layers with Only vector layers, like this:

layers = [layer for layer in iface.legendInterface().layers() if layer.type() == QgsMapLayer.VectorLayer]

instead of:

layers = iface.legendInterface().layers() 

good luck...

according to @Joseph's answer, if you want to populate your combobox with fields of vector layers, since raster layers does not have any fields of attribute you may get the error: AttributeError: 'QgsRasterLayer' object has no attribute 'fields'.

so for avoiding that you must equal your Layers with Only vector layers, like this:

layers = [layer for layer in iface.legendInterface().layers() if layer.type() == QgsMapLayer.VectorLayer]

instead of:

layers = iface.legendInterface().layers() 

good luck...

Source Link
Ash
  • 1.3k
  • 7
  • 22

according to @Joseph's answer, if you want to populate your combobox with fields of vector layers, since raster layers does not have any fields of attribute you may get the error QgsRasterLayer have no attribute Fields.

so for avoiding that you must equal your Layers with Only vector layers, like this:

layers = [layer for layer in iface.legendInterface().layers() if layer.type() == QgsMapLayer.VectorLayer]

instead of:

layers = iface.legendInterface().layers() 

good luck...