I'm looking to change a number of QGIS settings with a python script. Whilst I can find references to some specific keys through various questions/answers on StackExchange, I can't find a method to actually look these up myself.
The question How do I access QGIS program settings programmatically? indicates that I need to go into the source code to look these up. However, I'm only a novice with this scripting stuff, and don't really know where to start or what to look for.
Can you provide a generalised set of steps for finding these keys in the source code?
-
Your question is broad, what specific setting are you interested in? See, docs.qgis.org/2.14/en/docs/pyqgis_developer_cookbook/…artwork21– artwork212017年12月18日 21:17:56 +00:00Commented Dec 18, 2017 at 21:17
-
@artwork21 Right now I'm interested in toggling "Auto Open Form". However, what I'm really after is a method for answering this question myself (if that makes sense). Then I won't have to post another question on SE the next time I want to find a key.firefly-orange– firefly-orange2017年12月18日 21:50:50 +00:00Commented Dec 18, 2017 at 21:50
1 Answer 1
You can use the QSettings::allKeys() method by first importing it:
from PyQt4.QtCore import QSettings
Then
To get a list of current keys:
QSettings().allKeys()
To print all keys individually (for readability):
for keys in QSettings().allKeys(): print keys
To search for a specific key:
for keys in QSettings().allKeys(): if 'Qgis' in keys: print keys