【Qt】QSettings


【Proposal】

  1. read/parse ini file。

【Code and Related-file】

  1. data.ini
    [profile]
    name= sam lee
    brithday= 1980/01/01
  2. include define
    #include <QtDebug>
    #include <QSettings>
  3. code
    QSettings settings("data.ini", QSettings::IniFormat);
    settings.beginGroup("profile");
    const QStringList childKeys = settings.childKeys();
    foreach (const QString &childKey, childKeys)
                 qDebug() << settings.value(childKey);
    settings.endGroup();

【Result】

  1. Result
    QVariant(QString, "1980/01/01") 
    QVariant(QString, "sam lee") 

【Question】

  1. How to create ini file If file not exist?

【Reference】

  1. How to use QSettings to read INI file
    http://www.qtcentre.org/threads/21473-How-to-use-QSettings-to-read-INI-file
 

Ed32. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com