[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Interfacing with binary files: QDataStream issue
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2017-06-21 16:18:49
Message-ID: 97AE125A-68D1-42BC-B89B-0B7E6EE31591 () riverbankcomputing ! com
[Download RAW message or body]
On 19 Jun 2017, at 8:08 pm, Christopher Probst <christop.probst@gmail.com> wrote:
>
> 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?
Instead of...
color = QVariant()
...do...
color = QColor()
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic