Greetings. There is a code: serializing application settings made like QProperty into an ini file (because they told me that the registry is a bad style).

Settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()); QString path = Settings->fileName(); 

and a little later:

 const QMetaObject *metaobject = metaObject(); int count = metaobject->propertyCount(); for (int i = 0; i<count; ++i) { QMetaProperty metaproperty = metaobject->property(i); const char *name = metaproperty.name(); QVariant value = property(name); QString Key = QString(name); Settings->setValue(Key, value); } 

In the path variable, the path to the ini file is:

path = C: / Users / ILIA / AppData / Roaming / Highway Software / Vesta 2016.ini

From the Russian letters in the ways I left a long time. The file is not created. I thought there was no permission to write, I started it from under Visual Studio 2013 running from the administrator - there is no result. So that you do not think that I did not find the file, I searched for it through Everything with a query:

 *vesta*.ini 

where vesta is the name of the application, it is not. What's the matter? All information is written to the registry (although not always, I did not overcome it).

  • Found out what's wrong. You need to remove a not shown piece of code: `if (Key.compare (" UndoQueueSize ") == 0) {DebugBreak (); } Did not show, as counted as garbage. Why DebugBreak can influence this is not clear. - Ilia Ivanov

1 answer 1

The data is saved when the sync method is called, as well as when the destructor is called and by interval in the event loop. You create QSettings on the heap and probably complete the application right away without deleting the object.

Debagger stops all threads, so if you freeze the application after writing the settings, the settings do not have time to be saved.

  • Thank. I understood this an hour after writing the question, I was ashamed that I did not know such a simple thing. The question helped. - Ilia Ivanov