Le mer. 4 mars 2020 à 10:14, Håvard Tveite <[email protected]> a écrit :

> I guess that an empty list of layers is regarded as acceptable,
> as long as the parameter is present in the call.
> Perhaps you can use setMinimumNumberInputs to achieve what you
> want?
>
> Something like:
>
>            self.addParameter(
>                QgsProcessingParameterMultipleLayers(
>                    self.INPUT_LINES, self.tr <http://self.tr>("Lines"),
>                    QgsProcessing.TypeVectorLine,
>                    optional=False
>                ).setMinimumNumberInputs(1)
>            )
>
> Håvard
>

So I was missing something, thanks Håvard !

The working code is a bit different as setMinimumNumberInputs returns void.
I put it below if other people are running in the same issue:

        parameter = QgsProcessingParameterMultipleLayers(
                self.INPUT_LINES,
                self.tr("Lines"),
                QgsProcessing.TypeVectorLine,
                optional=False
            )
        parameter.setMinimumNumberInputs(1)
        self.addParameter(parameter)
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to