1

How do I toggle the edit mode for many layers with QGIS 3.16 and PostGIS layers? Maybe there is a plugin or a function in the UI.

I don't want to select each layer and switch the edit mode separately.

When I select some layers and use the toggle edit mode function, only one of the layers switches its mode.

3
  • 2
    But you can only edit one layer at a time - so why toggle editing for a bunch of them?
    – Erik
    Commented Sep 22, 2021 at 9:39
  • 4
    Have a look at oslandia.com/en/2017/10/10/… ( "Users can switch all the layers in edit mode at once. A real time saver.")
    – Thomas B
    Commented Sep 22, 2021 at 9:50
  • Thanks, this project option was unknown for me. Maybe that will help, because my users have to work with very complex situations with features from dozens of layers. And within a short time they have to update or insert features from many of this layers.
    – Peter
    Commented Sep 22, 2021 at 11:19

1 Answer 1

5

You can loop through layers you want to enable editing for and toggle editing in the Python console.

for lyr in QgsProject.instance().mapLayers().values():
    if lyr.name() in ['layer 1', 'layer 2', 'layer 3']:
        lyr.startEditing()

You could leave out the if to toggle editing for all layers, or use

lyr.name() not in ['layer 4' , 'layer 5']

if there are only a few you don't want to toggle editing on for

3
  • 2
    Yes, of course that is possible. But I was searching for a solution for "non-professional" users.
    – Peter
    Commented Sep 22, 2021 at 11:23
  • 2
    Then please be more specific in your question. Nowhere do you mention "non-professional users".
    – Matt
    Commented Sep 22, 2021 at 11:51
  • Yes, you are right. sorry. I edited the question now.
    – Peter
    Commented Sep 27, 2021 at 7:10

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.