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:

Qt Code:
  1. void Main::testsetting()
  2. {
  3. mysetting=new QSettings("test.ini",QSettings::IniFormat);
  4. if(mysetting->value("testvalue").toString()==testvalue)
  5. { //second run
  6. QMessageBox::information(this,"Check","Testvalue="+testvalue+ " is equal="+mysetting->value("testvalue").toString(),QMessageBox::Ok);
  7. }
  8. else
  9. { //first run
  10. QMessageBox::information(this,"Check","Testvalue="+testvalue+ " isn't equal="+mysetting->value("testvalue").toString(),QMessageBox::Ok);
  11. }
  12. mysetting->setValue("testvalue",testvalue);
  13. mysetting->sync();
  14. if(mysetting->status() ==QSettings::NoError) QMessageBox::information(this,"Save","Save successful",QMessageBox::Ok);
  15. else QMessageBox::information(this,"Save","Save error",QMessageBox::Ok);
  16. delete mysetting;
  17.  
  18.  
  19. }
To copy to clipboard, switch view to plain text mode 

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.testsetting.zip