[PyQt] empty container in QSettings: TypeError

Phil Thompson phil at riverbankcomputing.com
Fri Mar 29 10:32:11 GMT 2013


On Sun, 17 Mar 2013 12:39:32 +0100, Wilbert Berendsen <wbsoft at xs4all.nl>
wrote:
> Hi all,
> 
> When I store a list of strings (but happening to be empty) in
> QSettings (using QString and QVariant api 2):
> 
> e.g.:
> 
>>>> paths = []
>>>> QSettings().setValue('paths', paths)
> 
> Retrieving it yields a TypeError, instead of an empty list:
> 
>>>> QSettings().value('paths', [], 'QString')
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: unable to convert a QVariant of type 0 to a QMetaType of
> type 10
> 
> What is the most elegant way to circumvent this? cathing the TypeError
> and returning the empty list?
> 
> Best regards,
> Wilbert

I can't reproduce this. I need a short complete script that demonstrates
the problem and the version numbers you are using.

Phil


More information about the PyQt mailing list