Qsettings Erratic Behaviour
Solved
General and Desktop
-
I am getting erratic behaviour when retrieving saved parameters using Qsettings. Most of the time everything works as it should but occasionally values are returned as 0.0, without any other indication that anything is wrong. I haven't been able to reproduce the behaviour consistently but it seems to be related to heavy use of qDebug() statements.
I'm using Qt 5.9.1 on Ubuntu 16.04.
Relevant code fragments are below:
QCoreApplication::setOrganizationName("xxx Technologies"); QCoreApplication::setOrganizationDomain("xxxT.com"); QCoreApplication::setApplicationName("yyy"); QSettings settings; if (settings.value("Camera/FrameRate").isNull()) { settings.setValue("Camera/FrameRate",4); } frameRate = settings.value("Camera/FrameRate").toDouble();
Most of the time frameRate is read back correctly as a value greater than 0 but sometimes it is returned as 0.0.
We have noticed the same behaviour with other saved values as well.
Any ideas what I might be doing wrong or ways to verify that the file is actually there and ready before I try to read the value?