PDA

View Full Version : QSettings Not Finding INI File In Release



brixel
16th November 2015, 13:31
I've been searching for an answer for a bit this morning and finding lots of stuff on QSettings, but nothing to help me with this particular issue. In debug using QT Creator QSettings can locate my ini file just find, but in release mode it can no longer locate this file.

I've tried various locations ( where it should be looking for it ) but still no luck. I'm sure I'm just missing something simple as I'm very new to QT, so any help would be appreciated.

I'm just looking to pick up the file from the root of the application like this:


QSettings settings( "mysettings.ini", QSettings::IniFormat );

I'm currently trying to get this to work on OSX and will also need to handle Windows as well. Thanks.

anda_skoa
16th November 2015, 14:03
Using a relative file name means your application will look in its current working directory.

Are you sure you run both versions with the same working directory and does the program itself the working directory?

Are you also sure you want the config to be in the working directory and thus limit yourself to one working directory?

Cheers,
_

brixel
16th November 2015, 14:50
Correct and I've placed the file in the working directory but it doesn't find it. And yes, right now the working directory is fine, it's just for some initial testing on a few machines that aren't my development system.

d_stranz
16th November 2015, 18:29
Are you sure that your working directory is the same for both debug and release builds?

You could also explicitly tell QSettings where to look using QSettings::setPath().

anda_skoa
17th November 2015, 08:54
Correct and I've placed the file in the working directory but it doesn't find it. And yes, right now the working directory is fine, it's just for some initial testing on a few machines that aren't my development system.

Well, even for testing, wouldn't it be better to use some fixed path?
E.g. in the temp file location?

Cheers,
_

brixel
17th November 2015, 13:38
Thanks everyone for the assistance. I ended up using a set path to target the ini file for now.