Is it possible to open saved layout in layout designer(print composer) with Python?

QGIS Python API:

openLayoutDesigner(self, layout: QgsMasterLayoutInterface) → QgsLayoutDesignerInterface

Opens a new layout designer dialog for the specified layout, or brings an already open designer window to the foreground if one is already created for the layout.

New in version 3.0.

I have tried iface.openLayoutDesigner("layoutname") in python console, but I get error:

TypeError: QgisInterface.openLayoutDesigner(): argument 1 has unexpected type 'str'

I don't understand what argument 1 should be.

1 Answer 1


You should get the layout to open, first. Then pass the layout instance to openLayoutDesigner() method. You can't open a layout by passing its name to that method. The method expect you to pass QgsMasterLayoutInterface instance.

Try in this way:

l_out = QgsProject.instance().layoutManager().layoutByName("layoutname")
  • Thanks it works now. Because i want this inside plugin, I added self before openLayoutDesigner. self.iface.openLayoutDesigner(layout=l_out)
    – Wilho
    Commented Aug 8, 2018 at 8:56
  • To have iface inside a plugin, you can do "from qgis.utils import iface". No need to always have it in "self".
    – etrimaille
    Commented Aug 20, 2021 at 8:36

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.