Results 1 to 6 of 6

Thread: QSettings Not Finding INI File In Release

  1. #1
    Join Date
    Nov 2015
    Posts
    22
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QSettings Not Finding INI File In Release

    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:

    Qt Code:
    1. QSettings settings( "mysettings.ini", QSettings::IniFormat );
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSettings Not Finding INI File In Release

    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,
    _

  3. #3
    Join Date
    Nov 2015
    Posts
    22
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSettings Not Finding INI File In Release

    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.
    Last edited by brixel; 16th November 2015 at 16:02.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSettings Not Finding INI File In Release

    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().

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSettings Not Finding INI File In Release

    Quote Originally Posted by brixel View Post
    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,
    _

  6. #6
    Join Date
    Nov 2015
    Posts
    22
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSettings Not Finding INI File In Release

    Thanks everyone for the assistance. I ended up using a set path to target the ini file for now.

Similar Threads

  1. finding a string in text file
    By sammey_geek in forum Newbie
    Replies: 4
    Last Post: 24th August 2013, 10:13
  2. using QSettings to read an ini file
    By gye325 in forum Qt Programming
    Replies: 16
    Last Post: 3rd September 2011, 00:07
  3. How to use QSettings to read INI file
    By Cantora in forum Newbie
    Replies: 8
    Last Post: 16th June 2011, 09:14
  4. Replies: 0
    Last Post: 17th December 2010, 09:50
  5. Finding frame size of the video file
    By mrudula in forum Qt Programming
    Replies: 0
    Last Post: 16th August 2010, 13:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.