QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.HomeLocation) and os.path.expanduser('~') will return path to the user's home directory ("C:\Users\<user_name>") while the better/more_common/proper/recommended/whatever place for configuration files is somewhere under either "C:\Users\<user_name>\AppData\Local" or "C:\Users\<user_name>\AppData\Roaming". It's somewhat like storing settings in "~/.<app_name>" instead of "~/.config/<app_name>" on *nix.
On 02/03/2017 06:20 AM, Frank Rueter | OHUfx wrote: > Thanks. > I'm stuck with QT 4.8.5 at the moment so QStandardPaths is not > available, but I could use QDesktopServices instead, e.g.: > > QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.HomeLocation) > > > What would be the difference to os.path.expanduser('~') though? > > Cheers, > frank > > > > On 2/02/17 8:19 PM, Constantin Makshin wrote: >> Hi Frank. >> >> Looks like the host application uses QSettings::setPath() >> (http://doc.qt.io/qt-5/qsettings.html#setPath) to enforce a specific >> directory for configuration files. Calling that method from your code is >> obviously a bad idea (high risk of screwing up the host application), so >> your "fallback" is the easiest solution. It'll be even better if you >> replace the "~/.config" part with proper runtime detection of user >> settings' directory (e.g. >> QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)). >> >> On 02/02/2017 08:35 AM, Frank Rueter | OHUfx wrote: >>> In the meantime I am falling back on using this: >>> os.path.expanduser('~/.config/companyName/appName') >>> >>> While this does not give me the OS' native support directory for the >>> respective user at least it's consistent :) >>> >>> I'd still be interested in a QSettings solution though. >>> >>> Cheers, >>> frank >>> >>> On 2/02/17 4:51 PM, Frank Rueter | OHUfx wrote: >>>> Hi all, >>>> >>>> I have been using QSettings for reading/writing user settings. >>>> All works well until I run my (PySide) application inside a host >>>> application that is also written in QT, and which also uses the >>>> QSettings object. >>>> >>>> I am now struggling to understand how I can properly differentiate >>>> between the host application's settings instance and my own. >>>> In particular, I need to use QSettings().fileName() to determine the >>>> correct support path for my ini files for each platform. >>>> But this line gives me different values inside and outside the host >>>> application: >>>> >>>> QtCore.QSettings(QtCore.QSettings.IniFormat, >>>> QtCore.QSettings.UserScope, "companyName", "appName").fileName() >>>> >>>> E.g.: >>>> Outside the host application I get what I want: >>>> >>>> /Users/frank/.config/companyName/appName.ini >>>> >>>> But the return value is a completely different inside the host app and >>>> actually points to the host app's internal file structure. >>>> Fair enough too I guess. >>>> >>>> So my question is: >>>> How can I use QSettings to determine support paths etc while making >>>> sure that I don't accidentally mess with the host applications QSettings? >>>> >>>> Cheers, >>>> frank
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest