How to find the Qsettings is exists or not?
Hi,
I would like to setup an Qsetting which stores like username, theme the user used.
Before accessing the Qsetting, I want to Qsetting is present or I will create a new considering user login first time.
Code snippet:
QCoreApplication::setOrganizationName("gghh");
QCoreApplication::setOrganizationDomain("gghh.COM" );
QCoreApplication::setApplicationName("Library");
QCoreApplication::setApplicationVersion("1.0");
QSettings qAppSetUser;
qAppSetUser.setValue("UserName",pstrUserName);
qAppSetUser.setValue("Password",pstrPassword);
qAppSetUser.setValue("NamedUserName","NamedUserNam e");
qAppSetUser.setValue("AccessLevel","Level1");
Query: How to check the Qsetting - qAppSetUser is already exist or not/
Thanks in advance.
Re: How to find the Qsettings is exists or not?
You don't have to do the check. Just open QSettings object and try to read value for e.g. "UserName" key. If it's not there then the file is not present.
Re: How to find the Qsettings is exists or not?
Hi,
Thanks for the reply,
If the file is not, I am trying to access, will not throw an error? Could you pls share the code snippet, If you have.
Re: How to find the Qsettings is exists or not?
Read more about QSettings especially about QSettings::contains.
Re: How to find the Qsettings is exists or not?
Quote:
Originally Posted by
Mathan
If the file is not, I am trying to access, will not throw an error?
It will not throw an error.