1

I have created a new plugin in QGIS3 with PyQt5 using Plugins Builder and when i want to add my code in module.py gives an error

the code used is

    layers = self.iface.legendInterface().layers()
    layer_list = []
    for layer in layers:
            layer_list.append(layer.name())

    self.dlg.comboBox.addItems(layer_list)

the error message is

AttributeError: 'QgisInterface' object has no attribute 'legendInterface' Traceback (most recent call last): File "C:/Users/REDADRISSI/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\reda\module.py", line 187, in run layers = self.iface.legendInterface().layers() AttributeError: 'QgisInterface' object has no attribute 'legendInterface'

2
  • Hello Kadir, thanks for your reaction, i tried this solution and gives another error NameError: name 'QgsProject' is not defined Commented Apr 18, 2018 at 15:45
  • Adding from qgis.core import QgsProject will probably fix your problem. Commented Apr 18, 2018 at 15:48

0

Browse other questions tagged or ask your own question.