[PyQt] qvariant and python objects

Adam Tenderholt atenderholt at gmail.com
Sun Jun 22 23:21:07 BST 2008


I've created a QVariant object by passing a Python object
(specifically, a list of numpy arrays) to its constructor, and I'm
trying to have it read into a QDataStream object. Unfortunately, it
doesn't work and gives me the error 'QVariant::save: unable to save
type 428.'. The relevant code is below:

...
mimeData = QtCore.QMimeData()
encodedData = QtCore.QByteArray()
stream = QtCore.QDataStream(encodedData, QtCore.QIODevice.WriteOnly)
...
temp  = QtCore.QVariant(element.coords)
stream << temp
...

As near as I can tell (printing debug messages immediately before and
after), it has trouble with the 'stream << temp' line. Should I be
doing something else, or can I not use QVariants in this way?

This is with Python 2.5.1 on a Mac running OS X 10.5.3 with Qt 4.4.0,
sip 4.76, and PyQt 4.4.2.

Thanks,

Adam


More information about the PyQt mailing list