Qsettings, how to save an empty list

199 Views Asked by At

When you use QSettings IniFormat, an empty list is stored in the .ini file as @Invalid(). When you retrieve the value, you get 'None'. This obviously can cause problem when you expect a list.

Using defaultValue=[] doesn't help, you still get None.

As a workaround you can do something like

foo = settings.value('my_list) or []

But is there also a way to retrieve an empty list directly from the .ini file?

It could be that this is only an issue on Windows. (see https://github.com/frescobaldi/frescobaldi/issues/1137)

0

There are 0 best solutions below