2

I am searching for a way to save a layout as .qpt file, is that possible with PyQGIS and how?

1 Answer 1

4

Yes, you could use the following to define the layout and use the QgsLayout::saveAsTemplate() method:

layout = QgsProject.instance().layoutManager().layoutByName('layoutName')
layout.saveAsTemplate('path/to/layout.qpt', QgsReadWriteContext())

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.