ini parsing does not return value
-
Hi,
The following is a part of my code:QSettings iniSetting(_myIni,QSettings::IniFormat); iniSetting.setIniCodec("UTF8"); iniSetting.beginGroup("run"); _runTimeString = iniSetting.value("run_time").toString();
As long as the ini value of run_time is less than a day (e.g. 11:23:45) _runTimeString is as expected.
But when the value in the ini file is " 1 day, 0:08:44" - I get an empty string.Why is this happening and how can I fix it?
Thanks! -
So what's the actual value of 'run_time' in your ini file?
-
This is the line in the ini that is not parsed correctly:
run_time = 1 day, 0:08:44 -
@Noatqt said in ini parsing does not return value:
1 day, 0:08:44
This is no correct format for a QString. I would guess it's
run_time = "1 day, 0:08:44"
But to know it for sure try to write it our with QSettings into your ini file.
-
The ini file was created by a python script. all values in it are strings. The Qt application is reading an existing file.
Why is this line different from the line that is parsed correctly?correct parsing:
run_time = 0:08:44incorrect parsing:
run_time = 1 day, 0:08:44 -
@Noatqt
Is the problem to do with having a (non-quoted) space in the value in the file?Qt does not guarantee to read in an arbitrary
.ini
file produced by some other code. I don't know whether that is the case here.@Christian-Ehrlicher suggested you test what
QSettings
produces when saving that string. -
@Noatqt said in ini parsing does not return value:
to have Qt read values containing spaces?
QStringList is maybe worth a try.