Asker Asker - 1 year ago 100
Ini Question

QT - Where is config.ini

I wanted to save db's conenction in

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

I started in code with this:

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

Then i created 2 functions

  1. for savng settings:

    //_hostName is attribute I can access, so that's not an issue

  2. for reading settings

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

I initially called 1. and then 2.

It seems like that the
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 Source

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);