3

I'm trying to customize QGIS 3.4 interface to allow data display only. None of the default QGIS geospatial data editing functionalities should be exposed to the end user. Also, the users should not be allowed to mess with the interface, like changing layer properties, layer groups or layer ordering.

Using the standard "Interface Customization" option I could do most of the work, but I can still see a few unwanted options around:

  1. The Attribute Table window still shows a few buttons allowing users to edit vector layer attributes
  2. The "Layers" panel still shows a few options related to interface change (creating groups, removing layers etc.)
  3. If I right-click a layer, I can still access the context menu

See image below indicating what elements I'm mentioning:

enter image description here

I have gone through the widget customization option in the "Interface Customization", but none of the widgets seem to be related to these particular items.

I found a few posts mentioning PyQGIS for interface customization, but they did not provide much information that I could use in my scenario.

Other posts suggest that we develop a completely customized interface from QGIS libraries, which I would avoid at this stage as it doesn't fit in this project's budget.

Is there a easier way to hide/remove the buttons/options I have highlighted in the attached image?

0

1 Answer 1

3

You need use PyQgis for this:

Toc

toc = iface.mainWindow().findChild(QDockWidget,'Layers').children()[4]
toolBar = toc.children()[1].setVisible(False)

Layers context menu

ltv = iface.layerTreeView()
ltv.setMenuProvider( None )

For attribute dialog I'll give you 2 examples:

Attribute = iface.mainWindow().findChild(QDockWidget,'AttributeTable').children()[4]

Remove Editing Button

Attribute.findChildren(QAction ,'mActionToggleEditing')[0].setVisible(False) 

Remove Multi Editing Button

Attribute.findChildren(QAction ,'mActionToggleMultiEdit')[0].setVisible(False)

For acces to objectname use this and remove the other buttons

values = Attribute.findChildren(QAction)
for v in values:
    print (v.objectName())

If you want it to be hidden in many machines, you can make a plugin, without an icon, botton etc. and only in your __init__ execute this code or through the startup.py

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.