0

Using PyQGIS with QGIS v3

My script opens an empty QGIS project (thinking this would retain the path). I add some layers, perform a few tasks. All is good.

Now I want to close the project or I should say update the project and then close. Similar to clicking on Project / Save and then I guess Project / New to close out the project with a new empty project.

I have yet to find any way for what I thought would be the simplest of commands. I've tried

project = QgsProject.instance()
project.write

Thought this would be an easy find but I am having no luck.

1

1 Answer 1

0

You must looking for project.write() + project.clear(). Aren't you ? You can then add a condition that will trigger the Save/Close. You can also build a loop through the folder containing all your .qgz files to avoid the manuel opening.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.