I want to rewrite a projekt with new layers while owerwriting all old layers. I found the function removeAllMapLayers in the qgis.core api
But when i try:
project = QgsProject.instance()
project.removeAllMapLayers()
Where I am in a project with some layers. After trying the code I get this error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'QgsProject' object has no attribute 'removeAllMapLayers'
Is there any other way to empty all layer in a project? I want to write to the same project when it's empty.