[PyQt] Saving PyObjects QSettings

Lukas LuHe at gmx.at
Thu Jul 31 14:38:39 BST 2008


Hello,

I wanted to save a PyObject in my QSettings:

>>> from PyQt4.QtGui import *
>>> app = QApplication([])
>>> settings = QSettings()

>>> myDevices = list()
>>> device = dict()
>>> device["name"] = "just some testing"
>>> device["addr"] = "00:22:33:5A:52"
>>> myDevices.append(device)

>>> QVariant(myDevices)
<PyQt4.QtCore.QVariant object at 0x7f682c6b7c00>

>>> QVariant(myDevices).toPyObject()
[{'name': 'just some testing', 'addr': '00:22:33:5A:52'}]


But when I try to save this I get the following error:

>>> settings.setValue("test", QVariant(myDevices))
>>> QVariant::save: unable to save type 446.

Is there a way to save python objects?

Thanks,

Lukas Hetzenecker


More information about the PyQt mailing list