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.

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Sep 11 at 8:41
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.

answered Sep 12 at 23:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.