Swxctx_解闯

铭心刻骨,就要一意孤行;越是憧憬,越要风雨兼程;要走多远,才算走进森林_xc....

QT读取配置文件

void WriteSettings()
{
    //QSettings settings("Software Inc", "Spreadsheet"); // windows在注册表中建立建 Software Inc -> Spreadsheet
    QSettings settings("Option.ini", QSettings::IniFormat); // 当前目录的INI文件
    settings.beginGroup("DevOption");
    settings.setValue("mainFun", 25);
    settings.setValue("subFun", 40);
    settings.setValue("service", 1);
    settings.endGroup();
}
 
void ReadSettings()
{
    QSettings settings("Option.ini", QSettings::IniFormat);
 
    int mainFun = settings.value("DevOption/mainFun").toInt();
    int subFun = settings.value("DevOption/subFun").toInt();
    QString service = settings.value("DevOption/service").toString();
 
    qDebug() << "service" << service;
    qDebug() << "mainFun" << mainFun;
    qDebug() << "subFun" << subFun;
}
 
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
 
    WriteSettings();
    ReadSettings();
     
    return a.exec();
}

阅读更多
版权声明:欢迎大家提出意见,指出错误,互相交流。 https://blog.csdn.net/qq_28796345/article/details/51555189
个人分类: QT
所属专栏: C And C++-QT
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭