QSettings file location in Ubuntu ambiguous?
-
Hi,
In my Lubuntu application, I am using QSettings IniFormat.
I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.
Along with my settings INI file, I want to store a log file at the same location.
In a different section of my program, I use QSettings::fileName() to find the path to the log file.
However, the file path from ::fileName is instead /etc/xdg/xdg-Lubuntu/myOrg, not /etc/xdg/myOrg.
So of course I fail to open my log file using this path.Why is this?
Can it be corrected?
I am hesitant to "hack" this myself since this can have unexpected consequences.
If it is a bug it might even be corrected, and then my program might fail anyway after an update.:)BN
-
I should also mention this:
~$ echo $XDG_CONFIG_DIRS
/etc/xdg/xdg-Lubuntu:/etc/xdg:/etc:/usr/shareUnfortunately, I am too stupid to understand the QSettings docs regarding XDG_CONFIG_DIRS, the behaviour if there is more than one path in the list. Sorry.
BN
-
I should also mention this:
~$ echo $XDG_CONFIG_DIRS
/etc/xdg/xdg-Lubuntu:/etc/xdg:/etc:/usr/shareUnfortunately, I am too stupid to understand the QSettings docs regarding XDG_CONFIG_DIRS, the behaviour if there is more than one path in the list. Sorry.
BN
-
Thanks.
Your suggestion gives me the user scope, not the admin scope.
My problem is the admin.BTW, what doc are you referring to?
I am using the QAssistant. Can it be trusted?@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
BTW, what doc are you referring to?
-
Ok, QStringList::StandardPaths::standardLocations() is giving me a list of possible candidates. However, it will not tell me which location QSettings admin scope is actually using.
It is also clear that QSettings::fileName() is not doing what it claims to do. Why is it there?Not SOLVED yet.
-
Ok, QStringList::StandardPaths::standardLocations() is giving me a list of possible candidates. However, it will not tell me which location QSettings admin scope is actually using.
It is also clear that QSettings::fileName() is not doing what it claims to do. Why is it there?Not SOLVED yet.
@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
It is also clear that QSettings::fileName() is not doing what it claims to do
What is it doing instead?
-
Ok, QStringList::StandardPaths::standardLocations() is giving me a list of possible candidates. However, it will not tell me which location QSettings admin scope is actually using.
It is also clear that QSettings::fileName() is not doing what it claims to do. Why is it there?Not SOLVED yet.
@Bengt-0
I don't if this helps, but I looked at my Ubuntu system, which I presume is similar to your Lubuntu, and found the following equivalents to your situation:# echo $XDG_CONFIG_DIRS /etc/xdg/xdg-ubuntu:/etc/xdg # ls /etc/xdg/xdg-ubuntu ls: cannot access '/etc/xdg/xdg-ubuntu': No such file or directory # ls /etc/xdg autostart systemd user-dirs.defaults menus user-dirs.conf Xwayland-session.d
Sooo....
/etc/xdg/xdg-ubuntu
in$XDG_CONFIG_DIRS
does not actually exist. Same for your/etc/xdg/xdg-Lubuntu
? So I'm thinking that directory is not used, only the second one,/etc/xdg
is actually in use.Does that help any? Do you have a
/etc/xdg/xdg-Lubuntu
? If you do, is it perchance a symbolic link to..
or/etc/xdg
? -
@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
It is also clear that QSettings::fileName() is not doing what it claims to do
What is it doing instead?
-
@Bengt-0
I don't if this helps, but I looked at my Ubuntu system, which I presume is similar to your Lubuntu, and found the following equivalents to your situation:# echo $XDG_CONFIG_DIRS /etc/xdg/xdg-ubuntu:/etc/xdg # ls /etc/xdg/xdg-ubuntu ls: cannot access '/etc/xdg/xdg-ubuntu': No such file or directory # ls /etc/xdg autostart systemd user-dirs.defaults menus user-dirs.conf Xwayland-session.d
Sooo....
/etc/xdg/xdg-ubuntu
in$XDG_CONFIG_DIRS
does not actually exist. Same for your/etc/xdg/xdg-Lubuntu
? So I'm thinking that directory is not used, only the second one,/etc/xdg
is actually in use.Does that help any? Do you have a
/etc/xdg/xdg-Lubuntu
? If you do, is it perchance a symbolic link to..
or/etc/xdg
?I have /etc/xdg/xdg-Lubuntu, but it is not empty.
It contains some other stuff presumably for other applications.
And as said, my real prefs are stored at /etc/xdg/myOrg.
I have been able to apply a fix by making a symlink /etc/xdg/xdg-Lubuntu/myOrg -> /etc/xdg/myOrg.
But I think this is an ugly solution.My real problem is that I want to make an app installer for other users (open source LPGL), and then things like this are clearly undesirable. A more stable solution would be better.
But since
~$ echo $XDG_CONFIG_DIRS
/etc/xdg/xdg-Lubuntu:/etc/xdg:/etc:/usr/share
lists several config directories, I feel there should be a standard way of handling this.
But I do not know what it is.BN
-
I have /etc/xdg/xdg-Lubuntu, but it is not empty.
It contains some other stuff presumably for other applications.
And as said, my real prefs are stored at /etc/xdg/myOrg.
I have been able to apply a fix by making a symlink /etc/xdg/xdg-Lubuntu/myOrg -> /etc/xdg/myOrg.
But I think this is an ugly solution.My real problem is that I want to make an app installer for other users (open source LPGL), and then things like this are clearly undesirable. A more stable solution would be better.
But since
~$ echo $XDG_CONFIG_DIRS
/etc/xdg/xdg-Lubuntu:/etc/xdg:/etc:/usr/share
lists several config directories, I feel there should be a standard way of handling this.
But I do not know what it is.BN
@Bengt-0
So that there can be no misunderstanding, can you please run the following two commands and paste the output:ls -ld /etc/xdg/ ls -ld /etc/xdg/xdg-Lubuntu/
QSettings::fileName()
replies/etc/xdg/xdg-Lubuntu/myOrg
, which is not correct.Could you please supply the absolute minimum code to reproduce this, so that I/we can maybe copy & paste to see how it behaves for us. It would seem "surprising" for it not to report the actual file path it is using to access the file, one would assume it is using that path to open the
.ini
file.lists several config directories, I feel there should be a standard way of handling this.
In what way?
XDG_CONFIG_DIRS
is not a Qt thing, it's a Linux/XDG thing. If they have a:
-separated list of directories to look in then that is their affair. -
@Bengt-0
So that there can be no misunderstanding, can you please run the following two commands and paste the output:ls -ld /etc/xdg/ ls -ld /etc/xdg/xdg-Lubuntu/
QSettings::fileName()
replies/etc/xdg/xdg-Lubuntu/myOrg
, which is not correct.Could you please supply the absolute minimum code to reproduce this, so that I/we can maybe copy & paste to see how it behaves for us. It would seem "surprising" for it not to report the actual file path it is using to access the file, one would assume it is using that path to open the
.ini
file.lists several config directories, I feel there should be a standard way of handling this.
In what way?
XDG_CONFIG_DIRS
is not a Qt thing, it's a Linux/XDG thing. If they have a:
-separated list of directories to look in then that is their affair.@JonB
~$ ls -ld /etc/xdg
drwxr-xr-x 12 root root 4096 Oct 6 21:07 /etc/xdg
~$ ls -ld /etc/xdg/xdg-Lubuntu
drwxr-xr-x 9 root root 4096 Oct 6 21:16 /etc/xdg/xdg-LubuntuI will try to make a minimal code example.
The last comment is perhaps not a Qt thing.
Or is XDG_CONFIG_DIRS a Qt related environmental?
I am just curious that it seems to offer multiple possibilities of config paths, and I am ignorant of how to use this feature in practice. -
@JonB
~$ ls -ld /etc/xdg
drwxr-xr-x 12 root root 4096 Oct 6 21:07 /etc/xdg
~$ ls -ld /etc/xdg/xdg-Lubuntu
drwxr-xr-x 9 root root 4096 Oct 6 21:16 /etc/xdg/xdg-LubuntuI will try to make a minimal code example.
The last comment is perhaps not a Qt thing.
Or is XDG_CONFIG_DIRS a Qt related environmental?
I am just curious that it seems to offer multiple possibilities of config paths, and I am ignorant of how to use this feature in practice.@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
Or is XDG_CONFIG_DIRS a Qt related environmental?
No. Qt is using it, but does not set it, it is not a Qt creation. But Qt code might do the picking from the
:
-list directories or setfileName()
not to what you say it should do, I do not know.https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
https://askubuntu.com/questions/1179729/where-is-xdg-config-dirs-set$XDG_CONFIG_DIRS defines the preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory.
XDG is to do with your desktop.
If you want a one-page overview of what this is about, https://maex.me/2019/12/the-power-of-the-xdg-base-directory-specification/ seems simple.
-
@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
~$ ls -ld /etc/xdg
drwxr-xr-x 12 root root 4096 Oct 6 21:07 /etc/xdg
~$ ls -ld /etc/xdg/xdg-Lubuntu
drwxr-xr-x 9 root root 4096 Oct 6 21:16 /etc/xdg/xdg-LubuntuOK, so neither location is writable to a non-root user. I assume your application is not running as root. When you ask Qt for:
QString path=QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
it will not give you either of those locations because they are not writable.
I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.
Your user-specific. modifiable application configuration files should be in:
QStandardPaths::ConfigLocation
orQStandardPaths::AppConfigLocation
(On Linux under ~/.config)Along with my settings INI file, I want to store a log file at the same location.
That is very poor place to place a log file. For a system-wide tool the appropriate place would be /var/log (or use syslog). See Filesystem Hierarchy Standard (FHS) for more.
If your application log file is for user consumption, then it should go somewhere the user defines.
If your application log file is for debugging or similar use then you could use
QStandardPaths::AppDataLocation
orQStandardPaths::AppLocalDataLocation
(Windows)
If your application log file is for temporary purposes only then
QStandardPaths::TempLocation
-
@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
~$ ls -ld /etc/xdg
drwxr-xr-x 12 root root 4096 Oct 6 21:07 /etc/xdg
~$ ls -ld /etc/xdg/xdg-Lubuntu
drwxr-xr-x 9 root root 4096 Oct 6 21:16 /etc/xdg/xdg-LubuntuOK, so neither location is writable to a non-root user. I assume your application is not running as root. When you ask Qt for:
QString path=QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
it will not give you either of those locations because they are not writable.
I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.
Your user-specific. modifiable application configuration files should be in:
QStandardPaths::ConfigLocation
orQStandardPaths::AppConfigLocation
(On Linux under ~/.config)Along with my settings INI file, I want to store a log file at the same location.
That is very poor place to place a log file. For a system-wide tool the appropriate place would be /var/log (or use syslog). See Filesystem Hierarchy Standard (FHS) for more.
If your application log file is for user consumption, then it should go somewhere the user defines.
If your application log file is for debugging or similar use then you could use
QStandardPaths::AppDataLocation
orQStandardPaths::AppLocalDataLocation
(Windows)
If your application log file is for temporary purposes only then
QStandardPaths::TempLocation
@ChrisW67
Chris,I have a very good reason to put my log and config, and settings in a system-scope folder.
The software is driving a measurement system, to be configured and calibrated by a maintenance engineer as root user. The system config, calibration data and log of the accuracy are valuable and should not be risked of loss.Actually, what I call a "log file" might not qualify exactly as a log file in the regular sense. It is more of a receipt of a calibration operation, describing parameters used and the result of the calibration. This is done on a monthly basis, and it is desirable to have long term a history available of the equipment performance. To my (limited) experience, /var/log can be a pretty wild and crowded place, important things might be lost there.
The system is used daily by regular non-root users, and the user-scope prefs are placed in a standard user pref location. If the software binaries are updated, the config, calibration data and calibration logs are not touched. If a regular user is making a serious mistake, the config and calibration data are still safe.
So my requirements are a bit special.BN
-
@Bengt-0 said in QSettings file location in Ubuntu ambiguous?:
Or is XDG_CONFIG_DIRS a Qt related environmental?
No. Qt is using it, but does not set it, it is not a Qt creation. But Qt code might do the picking from the
:
-list directories or setfileName()
not to what you say it should do, I do not know.https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
https://askubuntu.com/questions/1179729/where-is-xdg-config-dirs-set$XDG_CONFIG_DIRS defines the preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory.
XDG is to do with your desktop.
If you want a one-page overview of what this is about, https://maex.me/2019/12/the-power-of-the-xdg-base-directory-specification/ seems simple.
-
Alright. You want to use the fallback mechanism to achieve this.
When the application is run effectively as root and you go to save the global configuration, calibration data etc. then you should use QSettings(QSettings::SystemScope). In that case the settings will go under /etc/xdg by default. Write the shared settings into a group named e.g., "Global".
When the application is not run as root (the vast majority of time), open QSettings (QSettings::UserScope).
User-specific settings should be written to and read from a group called e.g., "User", to avoid any potential for collision.
When the user reads from group "Global" they will see the the central configuration file because of the fallback mechanism. The user mode code should never call setValue() on values in the "Global" group because that will create settings locally that will then mask the central ones.#include <QCoreApplication> #include <QSettings> #include <QDateTime> #include <QDebug> #include <unistd.h> #include <sys/types.h> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QCoreApplication::setOrganizationName("Example"); QCoreApplication::setOrganizationDomain("example.com"); QCoreApplication::setApplicationName("Test"); uid_t euid = geteuid(); if (euid == 0) { QSettings settings(QSettings::SystemScope); qDebug() << "Running as root:" << settings.fileName(); // System-wide settings should only ever be written in here settings.beginGroup("Global"); settings.setValue("LastChange", QDateTime::currentDateTimeUtc().toString(Qt::ISODate)); settings.setValue("Calibration", 36); settings.endGroup(); } else { QSettings settings(QSettings::UserScope); qDebug() << "Running as user:" << settings.fileName(); // System-wide settings are visible and read-only in here qDebug() << "Global last change:" << settings.value("Global/LastChange"); qDebug() << "Global Calibration:" << settings.value("Global/Calibration"); // User-specific settings can be read/write in here qDebug() << "User last change:" << settings.value("User/LastChange"); qDebug() << "User fun count :" << settings.value("User/AmountOfMeasurementFun"); settings.beginGroup("User"); settings.setValue("LastChange", QDateTime::currentDateTimeUtc().toString(Qt::ISODate)); int funCount = settings.value("AmountOfMeasurementFun", 0).toInt(); settings.setValue("AmountOfMeasurementFun", ++funCount); settings.endGroup(); } return 0; }
Tests:
$ ls -ld /etc/xdg/Example ~/.config/Example ls: cannot access '/etc/xdg/Example': No such file or directory ls: cannot access '/home/chrisw/.config/Example': No such file or directory $ ./test Running as user: "/home/chrisw/.config/Example/Test.conf" Global last change: QVariant(Invalid) Global Calibration: QVariant(Invalid) User last change: QVariant(Invalid) User fun count : QVariant(Invalid)
There was no system config but a user config has now been written:
$ cat /home/chrisw/.config/Example/Test.conf [User] AmountOfMeasurementFun=1 LastChange=2022-10-08T02:22:24Z
Now a calibration session is run as root:
$ sudo ./test Running as root: "/etc/xdg/Example/Test.conf" $ cat /home/chrisw/.config/Example/Test.conf [User] AmountOfMeasurementFun=1 LastChange=2022-10-08T02:22:24Z $ cat /etc/xdg/Example/Test.conf [Global] Calibration=36 LastChange=2022-10-08T02:22:48Z
The user settings unchanged but now the system settings exist, the user sees them.
$ ./test Running as user: "/home/chrisw/.config/Example/Test.conf" Global last change: QVariant(QString, "2022-10-08T02:22:48Z") Global Calibration: QVariant(QString, "36") User last change: QVariant(QString, "2022-10-08T02:22:24Z") User fun count : QVariant(QString, "1") $ ./test Running as user: "/home/chrisw/.config/Example/Test.conf" Global last change: QVariant(QString, "2022-10-08T02:22:48Z") Global Calibration: QVariant(QString, "36") User last change: QVariant(QString, "2022-10-08T02:23:08Z") User fun count : QVariant(QString, "2")
The global settings are never in the user's configuration file.
$ cat /home/chrisw/.config/Example/Test.conf [User] AmountOfMeasurementFun=3 LastChange=2022-10-08T02:23:29Z
-
Hi,
In my Lubuntu application, I am using QSettings IniFormat.
I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.
Along with my settings INI file, I want to store a log file at the same location.
In a different section of my program, I use QSettings::fileName() to find the path to the log file.
However, the file path from ::fileName is instead /etc/xdg/xdg-Lubuntu/myOrg, not /etc/xdg/myOrg.
So of course I fail to open my log file using this path.Why is this?
Can it be corrected?
I am hesitant to "hack" this myself since this can have unexpected consequences.
If it is a bug it might even be corrected, and then my program might fail anyway after an update.:)BN
@Bengt-0
Firstly, please read through @ChrisW67's very thorough sample code in his last post.Going back to your original question/"bad" behaviour:
I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.
Along with my settings INI file, I want to store a log file at the same location.
In a different section of my program, I use QSettings::fileName() to find the path to the log file.
However, the file path from ::fileName is instead /etc/xdg/xdg-Lubuntu/myOrg, not /etc/xdg/myOrg.
I do not get this. In particular I do not get your "I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.". And I don't know how exactly this comes about for you, since you showed
~$ ls -ld /etc/xdg drwxr-xr-x 12 root root 4096 Oct 6 21:07 /etc/xdg
Since
/etc/xdg
is writable only byroot
, how did you get/etc/xdg/myOrg/
and what are its permissions/who is it writable by?Here is the test code I used:
#include <QCoreApplication> #include <QDebug> #include <QSettings> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QCoreApplication::setOrganizationName("Example"); QCoreApplication::setOrganizationDomain("example.com"); QCoreApplication::setApplicationName("Settings"); QSettings userSettings(QSettings::UserScope, "Example", "Settings"); qDebug() << userSettings.fileName(); userSettings.setValue("abc", "def"); userSettings.sync(); qDebug() << userSettings.status(); QSettings systemSettings(QSettings::SystemScope, "Example", "Settings"); qDebug() << systemSettings.fileName(); systemSettings.setValue("abc", "def"); systemSettings.sync(); qDebug() << systemSettings.status(); return a.exec(); }
[I have to use a slightly different
QSettings
constructor from you since I am on Qt 5.12, but it's the same effect.] Running as me, not root (is that your case too?). And my output is:"/home/jon/.config/Example/Settings.conf" QSettings::NoError "/etc/xdg/xdg-ubuntu/Example/Settings.conf" QSettings::AccessError
just as I would expect.
-
@Bengt-0
Firstly, please read through @ChrisW67's very thorough sample code in his last post.Going back to your original question/"bad" behaviour:
I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.
Along with my settings INI file, I want to store a log file at the same location.
In a different section of my program, I use QSettings::fileName() to find the path to the log file.
However, the file path from ::fileName is instead /etc/xdg/xdg-Lubuntu/myOrg, not /etc/xdg/myOrg.
I do not get this. In particular I do not get your "I can see that my settings INI file is stored in /etc/xdg/myOrg/ as expected.". And I don't know how exactly this comes about for you, since you showed
~$ ls -ld /etc/xdg drwxr-xr-x 12 root root 4096 Oct 6 21:07 /etc/xdg
Since
/etc/xdg
is writable only byroot
, how did you get/etc/xdg/myOrg/
and what are its permissions/who is it writable by?Here is the test code I used:
#include <QCoreApplication> #include <QDebug> #include <QSettings> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QCoreApplication::setOrganizationName("Example"); QCoreApplication::setOrganizationDomain("example.com"); QCoreApplication::setApplicationName("Settings"); QSettings userSettings(QSettings::UserScope, "Example", "Settings"); qDebug() << userSettings.fileName(); userSettings.setValue("abc", "def"); userSettings.sync(); qDebug() << userSettings.status(); QSettings systemSettings(QSettings::SystemScope, "Example", "Settings"); qDebug() << systemSettings.fileName(); systemSettings.setValue("abc", "def"); systemSettings.sync(); qDebug() << systemSettings.status(); return a.exec(); }
[I have to use a slightly different
QSettings
constructor from you since I am on Qt 5.12, but it's the same effect.] Running as me, not root (is that your case too?). And my output is:"/home/jon/.config/Example/Settings.conf" QSettings::NoError "/etc/xdg/xdg-ubuntu/Example/Settings.conf" QSettings::AccessError
just as I would expect.
@JonB
Jon,I sense some possible miscommunication here.
First, the listing of directory content.
I am using "ls-la" and not "ls -ld":$ ls -la /etc/xdg/ total 76 drwxr-xr-x 13 root root 4096 Oct 8 12:15 . drwxr-xr-x 130 root root 12288 Oct 7 08:32 .. -rw-r--r-- 1 root root 86 Mar 5 2022 accept-languages.codes drwxr-xr-x 2 root root 4096 Oct 7 08:00 autostart drwxr-xr-x 2 root root 4096 Oct 8 11:53 Example -rw-r--r-- 1 root root 153 Mar 5 2022 kshorturifilterrc drwxr-xr-x 2 root root 4096 Aug 9 13:50 libfm drwxr-xr-x 3 root root 4096 Aug 9 13:49 lxqt drwxr-xr-x 2 root root 4096 Aug 9 13:51 menus drwxr-xr-x 2 root root 4096 Oct 8 12:37 MYORG drwxr-xr-x 2 root root 4096 Aug 9 13:50 openbox drwxr-xr-x 2 root root 4096 Aug 9 13:47 systemd drwxr-xr-x 2 root root 4096 Aug 9 13:50 ui -rw-r--r-- 1 root root 414 Mar 25 2022 user-dirs.conf -rw-r--r-- 1 root root 418 Mar 25 2022 user-dirs.defaults drwxr-xr-x 9 root root 4096 Aug 9 13:51 xdg-Lubuntu drwxr-xr-x 2 root root 4096 Aug 9 13:51 Xwayland-session.d $ ls -la /etc/xdg/MYORG total 12 drwxr-xr-x 2 root root 4096 Oct 8 12:37 . drwxr-xr-x 13 root root 4096 Oct 8 12:15 .. -rw-r--r-- 1 root root 227 Oct 8 12:37 MYAPP.ini $ ls -la /etc/xdg/xdg-Lubuntu/ total 48 drwxr-xr-x 9 root root 4096 Aug 9 13:51 . drwxr-xr-x 13 root root 4096 Oct 8 12:15 .. drwxr-xr-x 2 root root 4096 Aug 9 13:51 autostart drwxr-xr-x 2 root root 4096 Aug 9 13:51 libfm drwxr-xr-x 2 root root 4096 Aug 9 13:51 lxqt -rw-r--r-- 1 root root 8468 Nov 14 2021 mimeapps.list drwxr-xr-x 2 root root 4096 Aug 9 13:51 nm-tray drwxr-xr-x 2 root root 4096 Aug 9 13:51 openbox drwxr-xr-x 3 root root 4096 Aug 9 13:49 pcmanfm-qt drwxr-xr-x 2 root root 4096 Aug 9 13:51 qterminal.org
Here you can see that MYORG resides in /etc/xdg, and MYAPP.ini is in /etc/xdg/MYORG. /etc/xdg/xdg-Lubuntu does not contain any of my files.
Now to the sample code, and this is interesting. Thanks for supplying the sample code, both of you, you were quicker than me.
The sample code from @ChrisW67 works correctly. I tried it and got the same result.
However, your code (JonB) reproduces my problem if I try it, and you also write this in your post."/home/jon/.config/Example/Settings.conf" QSettings::NoError "/etc/xdg/xdg-ubuntu/Example/Settings.conf" QSettings::AccessError
You seem to think this is ok and expected, you need to explain why to me.
I would expect qDebug() << systemSettings.fileName(); to give "/etc/xdg/Example/Settings.conf".
There is something I do not understand here.
BN