Results 1 to 6 of 6

Thread: QSettings vs (QFile + Qtextstream)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: QSettings vs (QFile + Qtextstream)

    Quote Originally Posted by jpn
    I'm not sure if you really can parse a specific ini file with QSettings
    Why not? The file format is similar as how QSettings would store it, right?

    If that doesn't work, take a look at QConfFileSettingsPrivate::readIniFile() in src/corelib/io/qsettings.cpp.
    Why can't i find this path on my installation (Suse 10)???

    Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QSettings vs (QFile + Qtextstream)

    Quote Originally Posted by nupul
    Why not? The file format is similar as how QSettings would store it, right?
    My mistake. The format is no problem at all. But I thought that QSettings would possibly do some assumptions about the path, eg. it's restricted to either $HOME/.config (user scope) or /etc/xdg (system scope) in *nix so you couldn't parse whichever file you want. But that seems not to be the case.

    Qt Code:
    1. QSettings settings("/home/user/Desktop/.desktop", QSettings::IniFormat);
    2. settings.beginGroup("Desktop Entry");
    3. QString exec = settings.value("Exec").toString();
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    nupul (10th April 2006)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QSettings vs (QFile + Qtextstream)

    Quote Originally Posted by nupul
    Why can't i find this path on my installation (Suse 10)???
    http://www.qtcentre.org/forum/showth...=9856#post9856
    J-P Nurmi

  5. #4
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink Re: QSettings vs (QFile + Qtextstream)

    Which implies that it is always preferable to use QSettings for such files, right?

    As the code you put forth is simpler and more elegant than using Qfile and Qtextstream and splitting the string on '='

    Thanks buddy!

Similar Threads

  1. QFile and QTextStream problems
    By uchennaanyanwu in forum Newbie
    Replies: 0
    Last Post: 7th August 2008, 02:44
  2. Detecting errors with QTextStream and QFile
    By December in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2008, 18:11
  3. QFile, QTextStream
    By Zergi in forum Newbie
    Replies: 1
    Last Post: 12th January 2008, 19:40
  4. QTextStream + QFile issue
    By trueneo in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2007, 15:16
  5. QFile, QTextStream, seek()
    By TheKedge in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2006, 15:07

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
  •  
Qt is a trademark of The Qt Company.