a.m.blub
4th April 2011, 06:56
Hi,
i have a little problem with my program.
I use Qsetting to load and write programsettings in a ini file.
I write a method to check settings in my file equal the current programsettings and if they are not equal to write the new settings in that file.
My problem when the Qsetting object can't write the settings in my file (settings in file and programsettings are different and file for test readonly) then say my method by second start that my filesettings and programsettings are equal. What is incorrect.
my method:
void Main::testsetting()
{
mysetting=new QSettings("test.ini",QSettings::IniFormat);
if(mysetting->value("testvalue").toString()==testvalue)
{ //second run
QMessageBox::information(this,"Check","Testvalue="+testvalue+ " is equal="+mysetting->value("testvalue").toString(),QMessageBox::Ok);
}
else
{ //first run
QMessageBox::information(this,"Check","Testvalue="+testvalue+ " isn't equal="+mysetting->value("testvalue").toString(),QMessageBox::Ok);
}
mysetting->setValue("testvalue",testvalue);
mysetting->sync();
if(mysetting->status() ==QSettings::NoError) QMessageBox::information(this,"Save","Save successful",QMessageBox::Ok);
else QMessageBox::information(this,"Save","Save error",QMessageBox::Ok);
delete mysetting;
}
The Qsetting class only use local in this method in my program.
I use Qt 4.7 under Linux and windows the same result.
Complete example in Attachments.6188
i have a little problem with my program.
I use Qsetting to load and write programsettings in a ini file.
I write a method to check settings in my file equal the current programsettings and if they are not equal to write the new settings in that file.
My problem when the Qsetting object can't write the settings in my file (settings in file and programsettings are different and file for test readonly) then say my method by second start that my filesettings and programsettings are equal. What is incorrect.
my method:
void Main::testsetting()
{
mysetting=new QSettings("test.ini",QSettings::IniFormat);
if(mysetting->value("testvalue").toString()==testvalue)
{ //second run
QMessageBox::information(this,"Check","Testvalue="+testvalue+ " is equal="+mysetting->value("testvalue").toString(),QMessageBox::Ok);
}
else
{ //first run
QMessageBox::information(this,"Check","Testvalue="+testvalue+ " isn't equal="+mysetting->value("testvalue").toString(),QMessageBox::Ok);
}
mysetting->setValue("testvalue",testvalue);
mysetting->sync();
if(mysetting->status() ==QSettings::NoError) QMessageBox::information(this,"Save","Save successful",QMessageBox::Ok);
else QMessageBox::information(this,"Save","Save error",QMessageBox::Ok);
delete mysetting;
}
The Qsetting class only use local in this method in my program.
I use Qt 4.7 under Linux and windows the same result.
Complete example in Attachments.6188