[PyQt] Interfacing with binary files: QDataStream issue
Christopher Probst
christop.probst at gmail.com
Mon Jun 19 20:08:30 BST 2017
Hi,
I am exploring interfacing of files with QDataStream. But it does not seem
to work. To write to a file I do this:
file = QFile("file.dat")
color = QColor(Qt.red)
if file.open(QIODevice.WriteOnly):
out = QDataStream(file)
out << color
file.flush()
file.close()
It looks as if that the data gets written to the file. It is the reading
where there is a problem:
file = QFile("file.dat")
color = QVariant()
if file.open(QIODevice.ReadOnly):
out = QDataStream(file)
out >> color
print(color)
print(color.value())
The output is:
<PyQt5.QtCore.QVariant object at 0x7f2cdd556f28>
None
What am I doing wrong?
Thanks,
Christopher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170619/6782be24/attachment.html>
More information about the PyQt
mailing list