5

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?

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

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

4

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.

  • That doesn´t work for the Outputs. – Herbert Santos Mar 28 at 16:02
  • That is a great idea! – AWGIS May 23 at 16:21
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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