[QGIS-Developer] QgsProcessingParameterField with parent layer based on a QgsProcessingParameterString
Nyall Dawson
nyall.dawson at gmail.com
Tue Jun 25 20:23:25 PDT 2019
On Wed, 26 Jun 2019 at 02:37, Tejas L <tejvan at live.com> wrote:
>
> Hello folks,
>
> I am writing a processing script where I need to select multiple fields from a loaded project layer. Normally I would use QgsProcessingParameterField and a parent QgsProcessingParameterFeatureSource to directly select the parent layer.
>
> However, in my use case I can only specify a substring of the parent layer name.
>
> e.g. Assume that the layers loaded in the current project are:
>
> xyz_proj1
> xyz_proj2
>
> I need a processing algorithm which takes two parameters:
> 1. substring: which is a layer name substring: e.g. "proj1"
> 2. field selector: which must be based on the fields of "xyz_proj1"
>
> How could I go about doing this?
You'll need to make a custom parameter type or widget. If you're using
a string as just a short cut GUI method to set a full layer, I'd
suggest writing your own GUI widget wrapper for this and keep on using
the feature source parameter. It's much less work, and will still work
correctly in models etc. If, on the other hand, there's more
complexity here then you'll probably need to resort to creating your
own parameter type.
Nyall
More information about the QGIS-Developer
mailing list