16,817
社区成员




频繁对一个ini文件setValue操作,会生成一个xx.ini.lock以及一个xx.ini.VCAzFK的两个中间文件,VCAzFK保存的是最新的写入数据,当我关闭程序时,这两个文件还存在,这就导致ini里面的数据不是最新,重启程序从ini获取到数据就不对,请问有什么办法刷新数据么?
QSettings can safely be used from different processes (which can be different instances of your application running at the same time or different applications altogether) to read and write to the same system locations, provided certain conditions are met. For QSettings::IniFormat, it uses advisory file locking and a smart merging algorithm to ensure data integrity. The condition for that to work is that the writeable configuration file must be a regular file and must reside in a directory that the current user can create new, temporary files in. If that is not the case, then one must use setAtomicSyncRequired() to turn the safety off.
使用setAtomicSyncRequired()关闭安全设置这两个文件应该就没了,但是对一个文件的修改应该是1个修改多个读,如果多个修改应该加锁,保证数据不脏