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'
from qgis.core import QgsProject
will probably fix your problem.