Asker Asker - 4 months ago 9
Ini Question

QT - Where is config.ini

I wanted to save db's conenction in

Config.ini
file. I created it and added to project (as "other file") - suitable record appered in
.pro
file.

I started in code with this:

QSettings settings(QDir::currentPath()+"/"+fileName, QSettings::IniFormat);


Then i created 2 functions


  1. for savng settings:

    settings.beginGroup("DB");
    settings.setValue("HostName",_hostName);
    //_hostName is attribute I can access, so that's not an issue
    settings.endGroup();

  2. for reading settings

    settings.beginGroup("DBSettings");
    _hostName =settings.value("HostName", "Unknown").toString();
    // hostName is attribute i can access
    settings.endGroup();



I initially called 1. and then 2.

It seems like that the
.ini
file is created and I could read from it, but it's not that I added to project and i can't find it in the folder it supposed to be.

It works, but I need to include it into the project and I need to be able to "control" it.

Answer

I resolved this problem myself. Turned out, that line :

QSettings settings(QDir::currentPath()+"/"+fileName, QSettings::IniFormat);

just has to be repalced with

settings = new QSettings(QDir::currentPath()+"/"+fileName, QSettings::IniFormat);
Comments