2

I would like to know how I can disable the 'save project' option in the QGIS print layout and report manager layout menus. I would also like to disable the save button on both gui's in PyQGIS 3.

Save Project from print layout Save project from the report manager Save project button on gui

For example: The following code snippets can disable elements of the project menu of the QGIS interface, I need to do the same for the print layout and report manager sub-gui's:

iface.actionCreatePrintLayout().setEnabled(False)
iface.actionShowLayoutManager().setEnabled(False)

Yields:

New print layout and layout manager disabled

1

You can use the following code to disable the Save Project button, just specify the name of the layout or report:

layouts = QgsProject.instance().layoutManager().layoutByName('reportOrLayoutName')
designer = iface.openLayoutDesigner(layouts)
layoutToolbar = designer.layoutToolbar()
for x in layoutToolbar.actions():
    if x.objectName() == 'mActionSaveProject':
        x.setEnabled(False)

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.