[Qgis-developer] virtual fields

Martin Dobias wonder.sk at gmail.com
Mon Mar 3 07:36:04 PST 2014

Hi Denis

On Mon, Mar 3, 2014 at 9:49 PM, Denis Rouzaud <denis.rouzaud at gmail.com> wrote:
> Hi all,
> I was wondering about the idea of being able to create simple views in QGIS,
> "views" in terms of database.
> Often, I use views (in postgres) to be able to create labels, title, simple
> calculation or whatever and also to combine data from joined tables.
> Somehow, all is already there in QGIS but in distinct features:
> - joins which will add the fields of the joined table to the main table
> - expressions are used in many places where views are meaningful: labels,
> styling, search, etc.
> - field calculation
> I was thinking that these features should be grouped and improved in what
> could be called virtual fields -- so basically a "live" field calculation
> without writing to the provider.
> First, the idea would be to define virtual fields using expressions.

I have thought about this functionality before and I think it should
be relatively easy to add this functionality. The
QgsVectorLayerFeatureIterator could simply compute the values of the
virtual fields according to their definition in QgsVectorLayer. It
should automatically work lazily - if the field is not requested, it
would not be evaluated.

> Then, it should be made possible to integrate the joined fields in qgis
> expressions without adding them to the current attributes (as it is now).
> One way to to it could be a function: joinField( joinName, joinedFieldName)
> Hence, the user would be allowed to choose which joined fields he really
> wants to be accessible in the layer.

Do we actually need such functionality? Wouldn't it be enough to hide
the attributes you don't want?


More information about the Qgis-developer mailing list