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
)
)