[PyQt] Re: Serious problem with QVariant v2 API and QSettings
phil at riverbankcomputing.com
Tue Dec 29 14:43:59 GMT 2009
On Tue, 29 Dec 2009 14:45:16 +0100, detlev <detlev at die-offenbachs.de>
> QSettings is not working correctly with the QVariant v2 API. Enter the
> following in a Python console.
>>>> import sip
>>>> from PyQt4.QtCore import *
>>>> s.setValue("k1", 1)
> Setting the variable s to None causes the contents to be written to
> After recreating the QSettings object, which causes the previously saved
> to be read, the formerly int value has changed to a unicode string. Same
> happens for bool values (and probably other Python types). A list of
> is changed to a list of strings.
...which is exactly what you would expect if the back-end format being
used doesn't store the types of values.
You have to convert the value to an object of the required type - just
like you do with the v1 API using one of QVariant's methods.
More information about the PyQt