9

Using QGIS 3 graphical modeler I created a model with a variety of input parameters (> 10). When starting the model, a nice user interface is generated. But the arrangement of the GUI elements is totally confused and apparently unpredictable during creating the model. It does neither seem to depend on the arrangement of input parameters in the graphical modeler nor on the chronological order in which the input parameters are added to the model.

Is there a way that let's me arrange the GUI elements in the order I desire?

1
  • You should be able to click and drag the GUI elements in any arrangement you like. Is this feature not working for you?
    – csk
    Commented Sep 24, 2018 at 20:37

4 Answers 4

6

Since QGIS 3.14 this is now possible using the Reorder Model Inputs... button at the bottom of the Inputs panel:

enter image description here

https://qgis.org/en/site/forusers/visualchangelog314/index.html#feature-allow-reordering-model-inputs

https://docs.qgis.org/testing/en/docs/user_manual/processing/modeler.html#interacting-with-the-canvas-and-elements

1
  • I love 3.14! This really makes my day! Commented Oct 23, 2020 at 13:06
5

Yes, there is a way.

when you set a new Input element, the name you give to it is like an ID. So, add an input and call it '0', it´ll be the first to be displayed, after you hit OK, it´s possible to change the name to any word, and the pseudo ID continuos to be '0'. So the next input should be '1', hit OK, change the name and so on.

the order QGIS create is based on numerical and alphabetic ascending order.

In that way I could rearrange a model with 9 inputs with no problem. I only needed to re-Add all the inputs to be in the order I wanted.

2
  • That doesn´t work for the Outputs. Commented Mar 28, 2019 at 16:02
  • That is a great idea!
    – AWGIS
    Commented May 23, 2019 at 16:21
4

Not as of QGIS 3.4 -- the order is always quasi-random.

3

Since QGIS 3.6 processing models can be exported as python algorithms (right click on the model):

enter image description here

This opens the resulting processing algorithm in the script editor.

The order of gui elements is defined in the method initAlgorithm():

from qgis.core import QgsProcessingParameterEnum
from qgis.core import QgsProcessingParameterFeatureSink
from qgis.core import QgsProcessingParameterVectorDestination
import processing


class BbbbProcessor(QgsProcessingAlgorithm):

    def initAlgorithm(self, config=None):
        self.addParameter(QgsProcessingParameterField('1formelfradrschlssel', ...
        self.addParameter(QgsProcessingParameterField('2formelfradressschlsselversorger', ...
        self.addParameter(QgsProcessingParameterField('3testaufkderschlossen', ...
        self.addParameter(QgsProcessingParameterVectorLayer('adr', ...
        self.addParameter(QgsProcessingParameterString('adrneinderschlflst', ...
        ...

The desired order of gui elements can be achieved by simply re-ordering the self.addParameter() method calls.

Note that this is more a workaround, since it hae to be done any time parameters change. If on the other hand only the process itself is changed and not the parameters, one may simply copy and paste the initAlgorithm() method.

1
  • Can you convert back the script to a graphic model? Commented Dec 26, 2019 at 18:01

Your Answer

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

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