Important

Translation is a community effort you can join. This page is currently translated at 47.25%.

5.3. Lesson: Formulare

Atunci când adăugați prin digitizare noi date, vi se prezintă o fereastră de dialog care vă permite să completați atributele entităților. Totuși, acest dialog nu este, în mod implicit, prea aspectuos. Acest lucru poate cauza o problemă de uzabilitate, mai ales dacă aveți de creat seturi de date de mari dimensiuni, sau dacă doriți ca alte persoane să vă ajute la digitizare, aceștia descoperind repede că formularele implicite sunt confuze.

Din fericire, QGIS vă permite să creați propriile dialoguri personalizate pentru un strat. Această lecție vă arată cum.

Scopul acestei lecții: De a crea un formular pentru un strat.

5.3.1. basic Follow Along: Utilizarea Funcționalității de Proiectare a Formularelor din QGIS

  1. Select the roads layer in the Layers panel

  2. Enter Edit Mode as before

  3. Open the roads layer’s attribute table

  4. Right-click on any cell in the table. A short menu will appear, that includes the Open form entry.

  5. Click on it to see the form that QGIS generates for this layer

Evident, ar fi frumos să fiți în măsură să faceți acest lucru, mai degrabă, în timp ce vă uitați la hartă, decât să fie nevoie să căutați tot timpul o stradă specifică în Tabela de Atribute.

  1. Select the roads layer in the Layers panel

  2. Using the identify Identify Features tool, click on any street in the map.

  3. The Identify Results panel opens and shows a tree view of the fields values and other general information about the clicked feature.

  4. At the top of the panel, check the Auto open form for single feature results checkbox in the options Identify Settings menu.

  5. Now, click again on any street in the map. Along the previous Identify Results dialog, you’ll see the now-familiar form:

    ../../../_images/roads_form.png
  6. Each time you click on a single feature with the Identify tool, its form pops up as long as the Auto open form is checked.

5.3.2. basic Try Yourself Folosirea Formularului pentru Editarea Valorilor

Dacă sunteți în modul de editare, puteți utiliza acest formular pentru a edita atributele unei entități.

  1. Activați modul de editare (dacă nu este deja activat).

  2. Using the identify Identify Features tool, click on the main street running through Swellendam:

    ../../../_images/main_street_selected.png
  3. Edit its highway value to be secondary

  4. Exit edit mode and save your edits

  5. Open the Attribute Table and note that the value has been updated in the attributes table and therefore in the source data

5.3.3. moderate Follow Along: Setarea Tipurilor de Câmpuri ale Formularelor

E frumos să editați lucruri folosind un formular, dar tot trebuie să introduceți manual totul. Din fericire, formele au așa-numitele widgets, care vă permit să editați datele în diverse moduri.

  1. Open the roads layer’s Properties…

  2. Mergeți la fila Câmpuri. Veți vedea următoarele:

    ../../../_images/fields_panel.png
  3. Switch to the Attributes Form tab. You’ll see this:

    ../../../_images/attributes_form.png
  4. Click on the oneway row and choose Checkbox as Widget Type in the list of options:

    ../../../_images/checkbox_selected.png
  5. Clic pe OK

  6. Enter edit mode (if the roads layer is not already in edit mode)

  7. Click on the identify Identify Features tool

  8. Click on the same main road you chose earlier

You will now see that the oneway attribute has a checkbox next to it denoting True (checked) or False (unchecked).

5.3.4. hard Try Yourself

Setați un widget mai adecvat pentru câmpul highway.

5.3.5. hard Try Yourself Crearea Datelor de Test

Aveți posibilitatea să proiectați, de asemenea, formularul propriu complet de la zero.

  1. Create a simple point layer named test-data with two attributes:

    • name (text)

    • age (integer)

    ../../../_images/new_point_layer.png
  2. Capturați câteva puncte de pe noul strat folosind instrumentele de digitizare, așa că veți avea un pic de date cu care să operați. Ar trebui să vedeți în continuare formularul implicit, generat de QGIS, de fiecare dată când capturați un nou punct.

    Notă

    Este posibil să trebuiască să dezactivați Acroșarea, dacă este activată în urma acțiunilor anterioare.

    ../../../_images/new_point_entry.png

5.3.6. hard Follow Along: Crearea unui Nou Formular

Now we want to create our own custom form for the attribute data capture phase. To do this, you need to have QT Designer installed (only needed for the person who creates the forms).

  1. Start QT Designer.

  2. În caseta de dialog care apare, creați un nou dialog:

    ../../../_images/qt_new_dialog.png
  3. Căutați Widget Box în partea stângă a ecranului (implicit). Aceasta conține un element denumit Line Edit.

  4. Faceți clic și trageți acest articol în formular. Aceasta va crea o nouă Linie de Editare în formular.

  5. Având selectat noul element de linie de editare, îi veți vedea proprietățile de-a lungul părții laterale a ecranului (din partea dreaptă, în mod implicit):

    ../../../_images/qt_line_edit.png
  6. Set its name to name.

  7. Using the same approach, create a new Spin Box and set its name to age.

  8. Add a Label with the text Add a New Person in a bold font (look in the object properties to find out how to set this). Alternatively, you may want to set the title of the dialog itself (rather than adding a label).

  9. Add a Label for your Line Edit and your Spin Box.

  10. Arrange the elements to your own desire.

  11. Faceți clic oriunde, în fereastra de dialog.

  12. Find the Lay Out in a Form Layout button (in a toolbar along the top edge of the screen, by default). This lays out your dialog automatically.

  13. Set the dialog’s maximum size (in its properties) to 200 (width) by 150 (height).

  14. Your form should now look similar to this:

    ../../../_images/qt_example_form.png
  15. Save your new form as exercise_data/forms/add_people.ui

  16. When it’s done saving, you can close Qt Designer

5.3.7. hard Follow Along: Asocierea Formularului cu Stratul Dvs.

  1. Go back to QGIS

  2. Dublu clic pe stratul test-data din legendă, pentru a-i accesa proprietățile.

  3. Click on the Attributes Form tab in the Layer Properties dialog

  4. În caseta cu lista derulantă Attribute editor layout, selectați Provide ui-file.

  5. Click the ellipsis button and choose the add_people.ui file you just created:

    ../../../_images/provide_ui_file.png
  6. Click OK on the Layer Properties dialog

  7. Enter edit mode and capture a new point

  8. Când faceți acest lucru, vă va fi prezentat dialogul personalizat (în loc de cel generic, pe care îl creează de obicei QGIS).

  9. If you click on one of your points using the identify Identify Features tool, you can now bring up the form by right clicking in the identify results window and choosing View Feature Form from the context menu.

  10. If you are in edit mode for this layer, that context menu will show Edit Feature Form instead, and you can then adjust the attributes in the new form even after initial capture.

5.3.8. In Conclusion

Folosind formularele, vă puteți face viața mai ușoară, atunci când editați sau când creați date. Prin editarea tipurilor de widget sau pin crearea unui formular cu totul nou, de la zero, puteți controla experiența cuiva care digitalizează date noi, minimizând, astfel, neînțelegerile și erorile inutile.

5.3.9. Further Reading

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.

5.3.10. What’s Next?

Deschiderea unui formular o dată cu identificarea unei entități este una dintre acțiunile standard, pe care o poate efectua QGIS. Cu toate acestea, puteți efectua direct acțiunile personalizate pe care le definiți. Acesta este subiectul lecției următoare.