How to build a QIODevice from Python IO object
-
wrote on 28 Aug 2023, 12:27 last edited by ejm1
Hello,
I have a class that implements the
RawIO
class in Python. I would like to write a QImage into this stream. I do not think its possible to directly write a QImage without manually pulling out the raw values so I was wondering if there is some way to build some kind of Qt object around this IO. The code I want to do is below but in Python and with a buffer from Python not Qt. Any help would be appreciated, thanks!QImage image; QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); image.save(&buffer, "PNG"); // writes image into ba in PNG format
-
Hi,
One starting point is to create a QIODevice subclass that has a RawIO object as class member and then re-implement the writeData method to write into that object.
Hope it helps
1/2