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())