1

I wrote a progressing algorithm using Python (QGIS 3.10.4). One of the input parameters is a .shp file where I defined as default. And if a user selects another .shp file than the default one, I want that the user chooses an attribute field of the selected layer which will be used for the categorized symbology later on.

Currently, my code is like this, and attribute fields appears regardless of the user selection. Can one do it that way that QgsProcessingParameterField appears only the user chooses something else than the default?

self.addParameter(
    QgsProcessingParameterVectorLayer(
        self.GEOLOGIE_LAYER,
        self.tr('Pfad zur Karte'),
        defaultValue=r"XXX\km500_geo_f.shp",
        optional=False
    )
)

self.addParameter(
    QgsProcessingParameterField(
        self.LABEL_FELD,
        self.tr('LABEL-FELD'),
        '',
        self.GEOLOGIE_LAYER,
        optional=False
    )
)
2
  • 2
    To my knowledge and some discussions with Nyall Dawson, this is currently not possible and intentionally designed that way to reduce GUI complexity in QGIS Processing.
    – root676
    Commented Jun 9, 2020 at 10:59
  • @KadirŞahbaz thanks for posting the link - that was exactly the question I had in mind when commenting. ;)
    – root676
    Commented Jun 9, 2020 at 12:14

0