Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to build a QIODevice from Python IO object
Forum Updated to NodeBB v4.3 + New Features

How to build a QIODevice from Python IO object

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 260 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ejm1
    wrote on 28 Aug 2023, 12:27 last edited by ejm1
    #1

    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
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Aug 2023, 19:08 last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      28 Aug 2023, 12:27

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved