qtqsettings

Qt: access the current settings file from anywhere in the code


Suppose I have a non-qt object. For example, the QT static-only log handler. How does one cause this file handler to know where to go to look for the current configuration file without, say, hard-coding the application name, organization etc. into the static log-handler function?

I have tried defining a global pointer to the configuration that gets initialized during a startup phase, but this turns out to be a hairy problem to solve during the linking phase. Is there some particular "only-way-is-the-best-way" solution?

(New to QT; if there is an "accepted" or "intended" approach, I would like to take that)


Solution

  • May be create global singleton class? Or set QSettings::setDefaultFormat() to ini near your binary?