Results 1 to 4 of 4

Thread: QSettings - .ini - and storing path to files

  1. #1
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QSettings - .ini - and storing path to files

    Hello,

    i am using QSettings and IniFormat in a windows-based project.

    The idea is to store some basic configuration data as .ini file - which basically works (write to & read from is fine).

    Now i am wondering what is the best idea to store entire path to files in an ini.

    One issue is the difference between linux path & windows paths - the other issue is the drive-letter.

    so the question is:
    What is the best way to store paths to files (windows env) in an .ini file - keeping the drive-letter and a working path_structure.


    Best regards
    el

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSettings - .ini - and storing path to files

    Qt on all platforms internally is using / (slash) in paths.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSettings - .ini - and storing path to files

    And there is ToNativeSeperators and friends to convert back and forth, so no need to do it yourself.

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSettings - .ini - and storing path to files

    for example:
    Qt Code:
    1. lastPath = appSettings->value("myFilePath",QApplication::applicationDirPath()).toString();
    2. ...
    3. appSettings->setValue("myFilePath", QFileInfo(fn).absolutePath());
    To copy to clipboard, switch view to plain text mode 

    Qt hides platform specific stuff - just try it

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.