[PyQt] Passing python objects in QDataStream with SIP api v2
Jugdish
jugdizh at gmail.com
Wed Mar 10 11:58:48 GMT 2010
How do you pass an arbitrary python object in/out of a QDataStream when you
have the SIP API set to version 2 for QVariants?
>>> import sip
>>> sip.setapi('QVariant', 2)
>>> from PyQt4 import QtCore
>>> data = QtCore.QByteArray()
>>> outstream = QtCore.QDataStream(data, QtCore.QIODevice.WriteOnly)
>>> outstream << {'foo':'bar'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for <<: 'QDataStream' and 'dict'
>>> outstream << QtCore.QVariant({'foo':'bar'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: PyQt4.QtCore.QVariant represents a mapped type and cannot be
instantiated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100310/28b1b087/attachment.html>
More information about the PyQt
mailing list