[Interest] Issue using QSettings INI format on Windows

Henry Skoglund fromqt at tungware.se
Fri Feb 8 23:41:25 CET 2019


On 2019-02-08 14:46, Murphy, Sean wrote:
> I'm porting an old application from Qt 5.3.2 to Qt 5.9.6 (yeah, I know, we're a lot behind...). I'm running into an issue where code we had that was writing out settings via the QSettings constructor that takes a file name doesn't work anymore. I've attached a fairly minimal example that shows this.
> 
> What I've found so far:
> - this code works perfectly on Windows using Qt 5.3.2 (mingw 4.8.2)
> - this code works perfectly on a Mac using Qt 5.9.6 (clang)
> - this code fails on Windows using Qt 5.9.6 (mingw 5.3.0)
> 
> Anyone have any ideas?
> 
> Sean
> 
> 

Hi, just tested your example program in MSVC 2017 Qt 5.12.1 and it fails 
as well.

But a simple fix is just to make sure that the QFile file isn't open at 
the same time as you write out the settings to it.
I.e. in your example program, it suffices to move that first 
file.close(); up to just before the "// write out via QSettings" comment 
line is, then it runs flawlessly.

But perhaps that's not possible to keep those writes separate in time in 
your "real" app that your porting?

Rgrds Henry




More information about the Interest mailing list