Pyside or pyqt does not have the qstring type in pythonv3, and is replaced by the STR type in Python. However, qbytearray exists. During pyside usage, conversion between qbytearray and Python bytes may be used. Google generally means that no conversion is required between qbytearray and bytes. In fact, eoferro is generated when qdatastream> bytes () is used. The following code:
Before Modification
Qdatasteam out (file)
Out <OBJ # obj is a python bytes object.
Qdatastring in (file)
OBJ = bytes ()
In> OBJ # generate eoferro
After modification
The Code is as follows:
Qdatasteam out (file)
Out <qbytearray (OBJ) # obj is a python bytes object.
# Because c ++ has implicit conversion, it can also be used as follows:
Out <OBJ
Qdatastring in (file)
TMP = qbytearray ()
In> TMP
OBJ = bytes (TMP. Data () # The read obj is the binary object to be saved.
To sum up:
C ++ implicitly converts the output stream. c ++ does not implicitly convert the input stream. In any case, manual conversion is the most secure.
- Bytes ---> qbytearray is:
OBJ = bytes ()
Qbyte = qbytearray (OBJ)
- Qbytesarray ----> bytes is:
Qbyte = qbytearray ()
OBJ = qbyte. Data () or OBJ = bytes (qbyte. Data ())
This problem occurs when I use pickle and QT in serialization.