Aha! Thanks<br><br><div class="gmail_quote">On Wed, Mar 10, 2010 at 12:52 PM, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Wed, 10 Mar 2010 11:58:48 +0000, Jugdish <<a href="mailto:jugdizh@gmail.com">jugdizh@gmail.com</a>> wrote:<br>
> How do you pass an arbitrary python object in/out of a QDataStream when<br>
you<br>
> have the SIP API set to version 2 for QVariants?<br>
><br>
>>>> import sip<br>
>>>> sip.setapi('QVariant', 2)<br>
>>>> from PyQt4 import QtCore<br>
>>>> data = QtCore.QByteArray()<br>
>>>> outstream = QtCore.QDataStream(data, QtCore.QIODevice.WriteOnly)<br>
>>>> outstream << {'foo':'bar'}<br>
> Traceback (most recent call last):<br>
> File "<stdin>", line 1, in <module><br>
> TypeError: unsupported operand type(s) for <<: 'QDataStream' and 'dict'<br>
>>>> outstream << QtCore.QVariant({'foo':'bar'})<br>
> Traceback (most recent call last):<br>
> File "<stdin>", line 1, in <module><br>
> TypeError: PyQt4.QtCore.QVariant represents a mapped type and cannot be<br>
> instantiated<br>
<br>
</div></div>QDataStream.readQVariant() and QDataStream.writeQVariant()<br>
<font color="#888888"><br>
Phil<br>
</font></blockquote></div><br>