When you add new data via digitizing, you’re presented with a dialog that lets you fill in the attributes for that feature. However, this dialog is not, by default, very nice to look at. This can cause a usability problem, especially if you have large datasets to create, or if you want other people to help you digitize and they find the default forms to be confusing.
Fortunately, QGIS lets you create your own custom dialogs for a layer. This lesson shows you how.
The goal for this lesson: To create a form for a layer.
Obviously it would be nice to be able to do this while looking at the map, rather than needing to search for a specific street in the Attribute Table all the time.
Select the roads layer in the Layers list.
Using the Identify tool, click on any street in the map.
The Identify Results panel opens and shows in a tree view the fields values and other general information about the clicked feature.
At the bottom of the panel, Check the Auto open form checkbox
Now, click again on any street in the map. Along the previous Identify Results dialog, you’ll see the now-familiar form:
Each time you click on a single feature with the Identify tool, its form pops-up unless the Auto open form is unchecked.
If you are in edit mode, you can use this form to edit a feature’s attributes.
Not
If you’re using the default dataset, you’ll find that there is more than one road on this map called Voortrek Street.
It’s nice to edit things using a form, but you still have to enter everything by hand. Fortunately, forms have different kinds of so-called widgets that allow you to edit data in various different ways.
You’ll now see that the man_made attribute has a checkbox next to it denoting True (checked) or False (unchecked).
You can also design your own custom form completely from scratch.
Not
You may need to disable Snapping if still enabled from earlier tasks.
Now we want to create our own custom form for the attribute data capture phase. To do this, you need to have Qt4 Designer installed (only needed for the person who creates the forms). It should be provided as part of your course materials, if you’re using Windows. You may need to look for it if you’re using another OS. In Ubuntu, do the following in the terminal:
Not
At the time of writing, Qt5 is the latest version available. However, this process specifically requires Qt4 and is not necessarily compatible with Qt5.
sudo apt-get install qt4-designer
... and it should install automatically. Otherwise, look for it in the Software Center.
Using forms, you can make life easier for yourself when editing or creating data. By editing widget types or creating an entirely new form from scratch, you can control the experience of someone who digitizes new data for that layer, thereby minimizing misunderstandings and unnecessary errors.
If you completed the advanced section above and have knowledge of Python, you may want to check out this blog entry about creating custom feature forms with Python logic, which allows advanced functions including data validation, autocompletion, etc.
Opening a form on identifying a feature is one of the standard actions that QGIS can perform. However, you can also direct it to perform custom actions that you define. This is the subject of the next lesson.