1

I update a list of WMS connections automatically with QgsSettings(). When the connection doesn't exist, it is well created with all good attributes. But when the connection already exists, and one attribute needs to be updated, the changes are not taken into account in the list of connections in the browser, but when I check the connection with the Python console, the attribute has been changed.

Here is how I do :

settings = QgsSettings()

for s in settings.allKeys():
    if s.startswith(my_key):
        if settings.value(s) != my_value
            settings.setValue(s, my_value)

iface.reloadConnections()
# I also tried :
# settings.sync()

And if I want to modify an existing connection, I need to remove it first, then with this code it is well initialized.

1

1 Answer 1

1

Ok I think I got a part of my answer. When looking at the exact keys created in the QgsSettings, some of the wms-connection keys start with connections/ows/items/wms/connections (dpi-mode, http-header, ignore-get-map-uri, url) and some with qgis/connections-wms (password, referer, username). So to update a connection you have to update the right keys.

Your Answer

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.