[QGIS-Developer] process bar in processing algs

pierluigi de rosa pierluigi.derosa at gmail.com
Tue Jul 20 21:51:18 PDT 2021


Thanks guys,

I solved my problem

In particular it was the feedback.progressChanged.connect suggested by
German the missing part.
Cheers
Pierluigi

Il giorno mar 20 lug 2021 alle ore 15:20 Germán Carrillo <
carrillo.german at gmail.com> ha scritto:

> Hi Pierluigi,
>
>
> you need to create your own *feedback* object and connect its
> *progressChanged* SIGNAL to your progressbar's *setValue* SLOT, in this
> way:
>
>
> feedback = QgsProcessingFeedback()
> feedback.progressChanged.connect(progressBarGrid.setValue)
>
> params_creategrid = {
>     # Set key-value parameters
> }
> result_grid = processing.run("native:creategrid", params_creategrid,
> feedback=feedback)
>
>
> Source: https://gis.stackexchange.com/a/348588/4972
>
>
> Regards,
>
> Germán
>
> El mar, 20 jul 2021 a las 4:52, matteo (<matteo.ghetta at gmail.com>)
> escribió:
>
>> Hi Pierluigi,
>>
>>
>> > can you please explain me better?
>> > I have self plugin that in particular part use this code
>> >
>> > result_grid = processing.run("native:creategrid", params_creategrid)
>>
>> as explained by Prem, if you want to add the progress when you call a
>> "native" algorithm of QGIS within your algorithm, then you can pass to
>> the algorithm parameters:
>>
>> result_grid = processing.run("native:creategrid", params_creategrid,
>> context=context, feedback=feedback)
>>
>> be aware also at the `is_child` parameter. Have a look at the example:
>>
>>
>> https://docs.qgis.org/3.4/en/docs/user_manual/processing/scripts.html#extending-qgsprocessingalgorithm
>>
>> if you want to add steps to the progressBar with your logic then you can
>> use feedback.setProgress(number) to fill the progress bar. Have a look
>> at the template script and you will find a fine usage
>>
>> Hope this helps
>>
>> Matteo
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
>
> --
> -----------
>    |\__
> (:>__)(
>    |/
> Soluciones Geoinformáticas Libres
> http://geotux.tuxfamily.org/
> https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2>
>
>

-- 
Ing. Pierluigi De Rosa (PhD in Earth Science)
Contract Professor of Geographic Information System at University of Perugia
cel: 3497558268 / fax: 075 7823038
skype: pierluigi.derosa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210721/06ff155f/attachment.html>


More information about the QGIS-Developer mailing list