I have a list ("datList") with names of raster layers which I want to add. When I add raster layers in the Python Console everything works fine:
for da in datListe:
layerDir = "C:/[path]/" + da
iface.addRasterLayer(layerDir,da)
When I do the same in a processing script with...
for da in datListe:
layerDir = "C:/[path]/" + da
rlayer = QgsRasterLayer(layerDir,da)
QgsProject.instance().addMapLayer(rlayer)
the layers are not added to my map. However, they seem to be in the project as
QgsProject.instance().mapLayers()
(typed in the Python Console) prints a list with the desired layers