July 21, 2012

bluestreak bluestreak
Lab Rat
33 posts

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

  1. [screen]
  2. position="one"
  3. [myConnection]
  4. ip="162.30.0.5"
  5. port=6543

In my Qt c++, I have
  1.     QSettings settings(QString("folderWithinHome/subfolder/states.ini"), QSettings::IniFormat);
  2.     QString someValue = settings.value("myConnection/ip", "none").toString();
  3.     qDebug() << someValue;

However, this returns “none.” Any ideas as to why it doesn’t correctly find the ip address in the .ini file?

1 reply

July 21, 2012

ChrisW67 ChrisW67
Robot Herder
404 posts

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.

 
  ‹‹ Mainwindow forms !!!      Qt and v8 javascript engine ››

You must log in to post a reply. Not a member yet? Register here!