I am searching for a way to save a layout as .qpt file, is that possible with PyQGIS and how?
1 Answer
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())