Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSettings not connecting to .ini file



  • Hi,

    I have a .ini file states.ini which I am trying to connect to QSettings. To test it out, in my .ini file I have
    @
    [screen]
    position="one"
    [myConnection]
    ip="162.30.0.5"
    port=6543
    @
    In my Qt c++, I have
    @
    QSettings settings(QString("folderWithinHome/subfolder/states.ini"), QSettings::IniFormat);
    QString someValue = settings.value("myConnection/ip", "none").toString();
    qDebug() << someValue;
    @
    However, this returns "none." Any ideas as to why it doesn't correctly find the ip address in the .ini file?



  • You have provided a relative file path to the ini file. My bet is that the current working directory of the running program is not what you think it is.


Log in to reply