I've stuck on a issue about getting a list of loaded layers. I've two layers loaded, one spatial (point, line or area) and another one non spatial (PostgreSQL table).
I've tried this code but it lists only the spatial layers:
layername = []
for i in iface.mapCanvas().layers():
layername.append(i.name())
print(layername)
I've tried QgsProject.instance().layerTreeRoot()
root = QgsProject.instance().layerTreeRoot()
ids = root.findLayerIds()
print(ids)
but it gives me a layer name plus an id.
How can I get a list of layer names from all loaded layers (spatial and non-spatial) in QGIS 3?
layers = [layer.name() for layer in QgsProject.instance().mapLayers().values()]– Joseph Feb 13 '19 at 10:56