Qt App Preferences Being Restored From A Cached Copy? (QSettings)
-
wrote 16 days ago last edited by steveDM 6 May 2025, 14:51
I've searched and prodded the black-box that is user Preferences while trying to debug my app's QSettings, and even if I delete them (in this case on my Mac, in /Library/Preferences), they reappear! Note this is true if I run a previous version of the same Qt App before these new Preferences existed!
To be clear:
Version X contains (only) an int to restore a value in a pulldown to that index.
Version X+1 adds a new preference, a QString, that's a UUID to identify this pulldown entry instead.
> Debugging version X+1 added this string to my preferences file.If I restore my preferences file to version X, or even DELETE them, runing version X (withOUT the QString) restores the QString to preferences.plist! This is true if version X is a Debug or Release build.
My gut says probably the Mac, or my Qt environment is caching this somewhere. I found a post that mentioned the .config folder, and there's nothing that seems relevant in there.
Can someone demystify me, please?
-
Hi,
From very old memories, it's macOS that has that cache. It might be in
~/Library/Caches
but that part I can't currently remember. -
wrote 15 days ago last edited by
Hi SG (me, too) -- thanks! There is a qmlcache folder in there containing lots of binary (xml/plist(?)) files which seem to be qml state related (searching some links), and I don't think they have anything to do with the reappearing plist. It's a little more knowledge into the qml performance world.
-
wrote 15 days ago last edited by
One more observation -- I put a quick look in QSettings.fileName(), and it's the usual preferences plist which is NOT on disk!?! (verified in terminal, not just finder).
-
I think its the defaults command we were looking for !
-
wrote 5 days ago last edited by steveDM
Hi -- thank you for the thought, sorry about the delay. I'm honestly not sure how that relates? I've tried to use
defaults
to see if I can find cached versions of the Preferences, but I haven't seen anything other than the usual -- for the user of an app, their preferences for that app are stored in ~/Library/Preferences/<AppID>.plist, and there are cached "binaries" in ~/Library/Caches/<Company>/<AppName>/qmlcache (qmlc files, which according to some docs suggests its for live state?).As the preferences I'm restoring are from [Q]Settings in a QML file, do you think they could be coming from a qmlc[ache] from a previous run? Asked another way, would QML look there in the absence of an OS-supplied preferences (which would have to behave similarly in e.g. Windows/Registry editing). FWIW there are a very large number of qmlc files in ~/Library/.../qmlcache.
Cheers!