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 that you have read and understand our privacy policy and code of conduct.

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