[PyQt] Re: Another problem with QVariant v2 API and QSettings

Phil Thompson phil at riverbankcomputing.com
Tue Dec 29 14:58:17 GMT 2009


On Tue, 29 Dec 2009 14:51:56 +0100, detlev <detlev at die-offenbachs.de>
wrote:
> Hi,
> 
> I just discovered another problem. Enter this code in a Python console.
> 
>>>> import sip
>>>> sip.setapi("QString",2)
>>>> sip.setapi("QVariant",2)
>>>> from PyQt4.QtCore import *
>>>> s=QSettings()
>>>> s.setValue("k6", {1:1, 2:2, 3:3})
>>>> s.setValue("k7", "Hello world")
>>>> s.value("k6")
> {1: 1, 2: 2, 3: 3}
>>>> s.value("k7")
> u'Hello world'
>>>> s=None
> QVariant::save: unable to save type 256.
>>>> s
>>>> s=QSettings()
>>>> s.value("k6")
> QVariant::load: unable to load type 256.
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> SystemError: error return without exception set
>>>> s.value("k7")
> u'Hello world'
> 
> The settings file contains these entries.
> 
> k6=@Variant(\0\0\0\x7f\0\0\0\xePyQt_PyObject\0)
> k7=Hello world

Works for me - it was fixed about 4 weeks ago.

Phil


More information about the PyQt mailing list