Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to hide all the fields at once in QGIS 1.7?

I see where I can hide one field at a time but I would like a button which does it all at once.

share|improve this question
Do you mean field attributes displayed in a layer? Or 'layers'? – Simbamangu Oct 23 '12 at 11:14
up vote 3 down vote accepted

with the GUI no but with a small Python script run in the Python console you can:

from qgis.utils import iface
layer = iface.activeLayer()
indexes = layer.pendingAllAttributesList()
for i in indexes:
      layer.setEditType(i, QgsVectorLayer.Hidden)

Copy and paste the following into the QGIS Python console and it should hide all the attributes on the layer.

share|improve this answer
What is the preferred way to save this bit of code in the interface somewhere? Or how easy is it to attach this to a ui button? I'd like to give a go at contributing to the project – Justin Oct 24 '12 at 11:47
@Nathan W- Has there been any GUI updates to bulk hide/show in 2.4? If not (for non-techies) what is the appropriate EditType to show the fields (opposite of QgsVectorLayer.Hidden)? – RyanDalton Jul 3 '14 at 20:03
Never mind about the code... I figured it out. To revert to the default setting, use: layer.setEditType(i, QgsVectorLayer.TextEdit). But is there a bulk on/off in the GUI? – RyanDalton Jul 3 '14 at 20:25

protected by underdark Jun 5 '14 at 11:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.