Results 1 to 5 of 5

Thread: Read INI file from QSetting

  1. #1
    Join Date
    Nov 2011
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Read INI file from QSetting

    Hi..
    I want to read from INI file with the help of QSettings and format is like
    12,34. ASD = 12,34. ASD
    mean in some values there is some integer and special characters in the key and value.
    In INI file if there is no integer or special characters then i am able to read,in that case there is no issue.
    But how to read the key and value with the help of QSettings.if there is some integer or characters are there.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Read INI file from QSetting

    The INI file has to be properly formatted. The output of the following program:

    Qt Code:
    1. #include <QSettings>
    2.  
    3. int main(int argc, char **argv) {
    4. QSettings settings("test.ini", QSettings::IniFormat);
    5. settings.setValue("12,34. ASD", "12,34. ASD");
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    states that the entry should be formatted as follows:


    [General]
    12%2C34.%20ASD="12,34. ASD"
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2011
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Read INI file from QSetting

    Thanks for reply,
    But i am not writing the INI file.
    getting the INI file from somewhere else and that is manually created i think.
    I am just reading the INI file.
    Scenario is like.. i am passing a value as string and now i find that value in INI file and returning the value.
    Qt Code:
    1. QString abc::readINI(QString oper)
    2. {
    3. QSettings settings("test.ini", QSettings::IniFormat);
    4. settings.beginGroup("aaa");
    5. QString var = settings.value(oper).toString();
    6. settings.endGroup();
    7. return var;
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by puneet; 25th March 2014 at 09:02.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Read INI file from QSetting

    The format you gave is invalid and Qt's parser will not be able to read it. You will either have to write your own parser or use an external library that is able to understand your data format.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2014
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Android

    Default Re: Read INI file from QSetting

    very good thanks poland friend.

Similar Threads

  1. how to read and write into an existing qsetting file
    By sliverTwist in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2013, 17:03
  2. Some QSetting Questions and some more...
    By aguayro in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2012, 13:43
  3. Read contents from the file using QHTTP Read()?
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 21st June 2011, 08:03
  4. is qt phonon can read realmedia file and divx file
    By fayssalqt in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2009, 15:42
  5. QSetting value() not correct
    By bpetty in forum Newbie
    Replies: 1
    Last Post: 14th August 2006, 19:58

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.