1

How can we access all the keys under QSettings() of QGIS 3.4 and above? Requirement is such that we need to set some QSettings() keys for smooth working of developed Plugins from outside of QGIS.

But I am not able to access the keys . If I run following lines in the Python Console (the one that comes with QGIS, inside QGIS/apps/Python37/Python.exe)

settings=QSettings()

settings.allKeys()

It results in an empty list. However same 2 lines if we run from QGIS Python Console it gives out all the Key Groups under which settings are stored.

How to access those Key Groups and how to modify them from outside of QGIS Environment?

1 Answer 1

2

Within QGIS Python console, get the ini file path from QSettings

settings = QSettings()
print(settings.fileName())

Then in your Python console, use path from above settings.fileName() like below

from PyQt5.QtCore import QSettings

settings = QSettings('/your/ini/path/ini', QSettings.IniFormat)
# Now working
print(settings.allKeys())
1
  • Thankyou very much ThomasG77. Commented Jul 25, 2021 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.