1

I'm making my first tool script in QGIS LTR (3.22.8). I'm following the answer given here about multiple layer parameters. I'm using the following code:

self.addParameter(
    QgsProcessingParameterMultipleLayers(
        self.INPUT,
        self.tr('Input layers'),
        [QgsProcessing.TypeVectorAnyGeometry]
    )
)

I get this error:

ScriptEditorDialog.py", line 253, in runAlgorithm alg.initAlgorithm() File "", line 105, in initAlgorithm NameError: name 'QgsProcessingParameterMultipleLayers' is not defined

Why is this? I'm using the Python template, and the method QgsProcessingParameterMultipleLayers appears in the autocomplete.

0

1 Answer 1

1

You need to import it first:

from qgis.core import QgsProcessingParameterMultipleLayers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.