Re: [QGIS-Developer] How to retrieve all "virtual fields" of a layer?

2017-06-01 Thread Matthias Kuhn 🌍
Hi Stefan

for attr_idx in range(l.fields().count()):
if l.fields().fieldOrigin(attr_idx) == QgsFields.OriginExpression:
print(l.fields()[attr_idx].name())

Cheers
Matthias

On 06/01/2017 02:53 PM, Stefan Keller wrote:
> Thanks Etienne,
>
> But I'm looking for a list of virtual fields (not virtual C++
> functions) from a PyQGIS accessor as they can be defined by the user
> in the "Field Calculator".
>
> :Stefan
>
> 2017-06-01 3:23 GMT+02:00 Etienne Trimaille :
> > Hi,
> >
> > Both layer.fields() or layer.pendingFields() work for me. I got my virtual
> > field.
> >
> > 2017-06-01 3:34 GMT+08:00 Stefan Keller :
> >>
> >> Hi,
> >>
> >> In a Python plugin I want to retrieve information about all
> >> attributes/fields of a layer
> >> In the cookbook [1] it's described how to retrieve thems
> >>   for field in layer.pendingFields():
> >>   print field.name(), field.typeName()
> >>
> >> => But how do I get all "virtual fields" programmatically?
> >>
> >> :Stefan
> >>
> >> [1]
> >> http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#retrieving-information-about-attributes
> >> ___
> >> QGIS-Developer mailing list
> >> QGIS-Developer@lists.osgeo.org
> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
> >
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] How to retrieve all "virtual fields" of a layer?

2017-06-01 Thread Stefan Keller
Thanks Etienne,

But I'm looking for a list of virtual fields (not virtual C++
functions) from a PyQGIS accessor as they can be defined by the user
in the "Field Calculator".

:Stefan

2017-06-01 3:23 GMT+02:00 Etienne Trimaille :
> Hi,
>
> Both layer.fields() or layer.pendingFields() work for me. I got my virtual
> field.
>
> 2017-06-01 3:34 GMT+08:00 Stefan Keller :
>>
>> Hi,
>>
>> In a Python plugin I want to retrieve information about all
>> attributes/fields of a layer
>> In the cookbook [1] it's described how to retrieve thems
>>   for field in layer.pendingFields():
>>   print field.name(), field.typeName()
>>
>> => But how do I get all "virtual fields" programmatically?
>>
>> :Stefan
>>
>> [1]
>> http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#retrieving-information-about-attributes
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] How to retrieve all "virtual fields" of a layer?

2017-05-31 Thread Etienne Trimaille
Hi,

Both layer.fields() or layer.pendingFields() work for me. I got my virtual
field.

2017-06-01 3:34 GMT+08:00 Stefan Keller :

> Hi,
>
> In a Python plugin I want to retrieve information about all
> attributes/fields of a layer
> In the cookbook [1] it's described how to retrieve thems
>   for field in layer.pendingFields():
>   print field.name(), field.typeName()
>
> => But how do I get all "virtual fields" programmatically?
>
> :Stefan
>
> [1] http://docs.qgis.org/testing/en/docs/pyqgis_developer_
> cookbook/vector.html#retrieving-information-about-attributes
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] How to retrieve all "virtual fields" of a layer?

2017-05-31 Thread Stefan Keller
Hi,

In a Python plugin I want to retrieve information about all
attributes/fields of a layer
In the cookbook [1] it's described how to retrieve thems
  for field in layer.pendingFields():
  print field.name(), field.typeName()

=> But how do I get all "virtual fields" programmatically?

:Stefan

[1] 
http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#retrieving-information-about-attributes
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer