3

How can I remove specific parts of QGIS toolbar? I know I can remove toolbars using this line of code:

iface.fileToolBar().setVisible(False)

But what I want is to delete every icon in the fileToolBar except save project and save project as icons, using Python.

enter image description here

2
  • 4
    You can customize the QGIS GUI via Settings --> Interface Customization.... If you still need a Python solution, just iterate iface.fileToolBar().actions(), ask for each action's objectName(), compare to those you want to preserve and for those actions that don't match, use iface.fileToolBar().removeAction(action). Dec 30, 2019 at 14:04
  • Python solution is what I need, thanks!
    – DrJacoby
    Dec 31, 2019 at 6:30

1 Answer 1

3

You can customize the QGIS GUI via Settings --> Interface Customization...

However, since you are looking for a Python solution:

  1. Iterate iface.fileToolBar().actions()
  2. Ask for each action's objectName() and compare to those you want to preserve
  3. And, finally, for those actions that don't match, use iface.fileToolBar().removeAction(action).

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.