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.

asked Jul 10, 2022 at 15:25
0

1 Answer 1

1

You need to import it first:

from qgis.core import QgsProcessingParameterMultipleLayers
answered Jul 10, 2022 at 15:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.