[QGIS-Developer] How to set QgsSettings to show up in "new settings tree widget"

Denis Rouzaud denis.rouzaud at gmail.com
Fri Apr 4 06:23:08 PDT 2025


Hi,

I realize now that it's not documented for Python yet.
There is a show description in the developer guidelines:
https://docs.qgis.org/3.40/en/docs/developers_guide/codingstandards.html#settings

The important bits are to correctly create and remove the settings node for
your plugin and to have only one instance of the node!
It might be easier with a real example for now:

https://github.com/opengisch/qgis-swiss-locator/blob/a21df5587b59e1f1f56762e26022441ed5b5db3d/swiss_locator/swiss_locator_plugin.py#L105
https://github.com/opengisch/qgis-swiss-locator/blob/master/swiss_locator/core/settings.py

I'll try to make the docs up to date in the future!

Denis


Le ven. 4 avr. 2025 à 14:56, Etienne Trimaille via QGIS-Developer <
qgis-developer at lists.osgeo.org> a écrit :

> Hi,
>
> Did you find something related to plugin settings ?
>
> I'm fine to update the docs if there are some hints.
> https://docs.qgis.org/3.40/en/docs/pyqgis_developer_cookbook/settings.html
> Or maybe better in the PyQGIS doc straight ?
>
> Le sam. 28 déc. 2024 à 10:06, Richard Duivenvoorde via QGIS-Developer <
> qgis-developer at lists.osgeo.org> a écrit :
>
>> Hi Dev's,
>>
>> What is the proper way to write plugins/QgsSettings in a plugin, AND let
>> them (also) show up in the "new settings tree widget" ?
>>
>> I've tried (using the a predefined Plugins setting like in the api docs:
>>
>> https://qgis.org/pyqgis/master/core/QgsSettings.html#qgis.core.QgsSettings.Plugins
>> :
>>
>> s=QgsSettings()
>> s.beginGroup("settingstest",QgsSettings.Plugins)
>> s.setValue("foo", 1)
>> s.endGroup()
>> s.sync()
>>
>> Then that value shows up in the old settings widget (in
>> 'plugins/settingstest', but not yet in the new tree.
>> While that shows other settings.
>> Apparently I'm missing something?
>> Or isn't the python part not yet done?
>>
>> Thanks for any pointers.
>>
>> Regards,
>>
>> Richard Duivenvoorde
>>
>>
>> _______________________________________________
>> 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
>>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20250404/c79522a3/attachment.htm>


More information about the QGIS-Developer mailing list