QGIS and Editing: Widgets

May 15, 2020 | FOSS4G, QGIS

I’ve been getting more questions lately on QGIS from all over the place. A pandemic will apparently: cause you to experiment with software, do some weird things with existing software, or call me up and ask “How do you work from home this sucks”. So one question started out with “I need to edit some data for the team and I need to keep up with what I edited and no it’s not in a database”.

In my perfect world you edit against postgresql/postgis and I set up some triggers to at the very least record who and when and possibly X and Y (or Y and X).  If you’re stuck with a shapefile, spatialite database, or Geopackage what can you do? So you have these things called widgets in QGIS……

So we’re going to play with a geopackage because that gives me some talking points for the next blog post. The ruggedly handsome client (me) has shoved some data into a geopackage. Geopackage has no login so I’m going to add my data to QGIS and do the following things:

  • Add two fields called ‘edituser’ and ‘editdate’
  • Set up two widgets in your QGIS Session.

If you right click on a data layer and go to properties you can set up a widget for your fields (under Attribute Forms). A widget can be a drop down list (something like a domain on a subtype for you over in ESRI Land).

So for the edituser field I will pick a simple text edit widget with a default value of ‘rjhale’ (At the Bottom of the menu).

The editdate field gets slightly more complicated. For that one I reach into the myriad of QGIS functions and pull out the $now. So I apply it as a default (and check that I want it to update if I move the line):

 

So moving forward I can at least keep up with “who” edited and “when”.

That’s possible the simplest use case of a widget you can have. What if you wanted to update the length of a line automatically? The QGIS Function is $length and you could apply that as a default to a widget on a field and have it calculate the length.

The big take away on this is you can do some very simple things to help your editing life. Two widgets with default values and you can keep up with what you’ve done (or maybe a co-worker) in an attempt to combine the data back together at a later time. A giant shoutout to Spatial Thoughts as I start to dive into more widget magic over the next bit.

 

You may also like

QGIS and LIDAR

So this will be my last "New Class" announcement for a bit. Back in the spring of 2024, I taught a 4 hour QGIS and LIDAR class at the TNGIC meeting (State of TN GIS meeting). I ran through it and shelved it and now I'm fixing the problem spots and smoothing down the...

NENA 911 Database in QGIS

NENA 911 Database in QGIS

I work with two counties in TN with the TN NG911 standard. Flash back 10 years ago and I hadn't really grasped how complicated address is. Do I like it? Mostly Yes. Occasionally I get questions from outside TN and I demo the two counties and how that works. A while...

Watershed GIS Part 1

Watershed GIS Part 1

I typically spend June wondering about what I'm doing, have done, and need to do work wise. One thing I keep thinking about is "the old days". By old days I mean the start of my career which was doing a lot of Watershed Mapping. Back in the mid 90's we would be...