You hit up all the forums at once with your question don't ya? (stackoverflow, qt-project.org, python_inside_maya) ;-)
Is this for python3? Placing 'b' in front of the string literal doesn't do anything in python2, and in python3 it doesn't create a bytearray, it creates a bytes instance. So really in your example (if in python2), you are just creating a string and passing it to QByteArray. It seems someone has answered your question about QTextStream though: http://stackoverflow.com/questions/16963464/how-to-convert-python-s-byte-array-to-qbytearray On Jun 7, 2013, at 1:34 AM, iMath wrote: > > I have a python ‘s byte array > b=b'hello' > and I want to use it as the parameter of QtextStream to create a QtextStream > object ,but QtextStream accept Qt’s byte array rather than Python’s .I wonder > is there anyway to to convert python ‘s byte array to QByteArray ? > > I’ve tested the following code ,it seems I cannot do it in this way . > > >>>> b=b'hello' >>>> from PyQt4.QtCore import * >>>> c=QTextStream(QByteArray(b)).readAll() >>>> c > '' >>>> > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
