INI file gets over written in Qt
I am creating a config file which stores username, password and role of certain user. I use the following code.
Code:
void MainWindow::OnAssignButtonClicked()
{
QString userName
= lineEditUsername.
text();
QString password
= lineEditPassword.
text();
QString Role
= comboBox.
currentText();
QList<QString> listUsername;
QList<QString> listPassword;
QList<QString> listRole;
QVariantMap userPasswordMapping;
QVariantMap userRoleMapping;
listUsername << userName;
listPassWord << Password;
listRole << Role;
for(int i = 0; i < listUsername.size() ; i++)
{
userPasswordMapping[user] = pass;
userRoleMapping[user] = role;
}
// Store the mapping.
settings.setValue("Password", userPasswordMapping);
settings.setValue("Role",userRoleMapping);
}
The first time the value gets written correctly. However if I run the program again the value over writes the old values. Can some one please suggest me a solution here?
Thank You
Re: INI file gets over written in Qt
You are calling setValue() so the value for that key is stored in the settings. Did you expect it to be different?
Re: INI file gets over written in Qt
Ok so what change should I do?
Re: INI file gets over written in Qt
Quote:
Originally Posted by
SiddhantR
Ok so what change should I do?
I have no idea what you want to achieve.