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


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())
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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