Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide compared to PyQt4 : problem with QImage __init__()
QtWS25 Last Chance

PySide compared to PyQt4 : problem with QImage __init__()

Scheduled Pinned Locked Moved Language Bindings
5 Posts 2 Posters 4.3k Views
  • 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.
  • L Offline
    L Offline
    lbordier
    wrote on 24 Nov 2010, 21:37 last edited by
    #1

    Hello,

    I'm trying to create a pyside backend for matplotlib by modifying the qt4agg backend.
    Now i'm stuck with a QImage problem :

    In PyQt4 the syntax is :

    img = QtGui.QImage(stringBuffer, 640,480,QtGui.QImage.Format_ARGB32)

    But converting to PySide raise an error because no init method accept these inputs (because of stringBuffer data).
    I tried with the staticmethod QImage.fromData(stringBuffer) but it does not work.

    I don't understand why pyside does not have the QImage ( uchar * data, int width, int height, Format format ) constructor ??

    Could someone help me on this topic ?
    How can i have the same result with a pyside syntax ?

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mairas
      wrote on 25 Nov 2010, 08:50 last edited by
      #2

      Hi,

      This is a bug in PySide - see:

      http://bugs.openbossa.org/show_bug.cgi?id=489

      Add yourself as a CC to the bug to get automatic updates about its progress.

      Due to the bug backlog we have, it might take a month or so before we have time to fix that, though. :-(

      Anyway, it's utterly cool that you're working on a matplotlib backend! I've really used matplotlib a lot for different kinds of projects of my own, and have always found the visual quality quite unmatched!

      ma.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lbordier
        wrote on 25 Nov 2010, 09:21 last edited by
        #3

        OK, thanks for the reply.
        Is there any way to get it working with methods like fromData or loadFromData ?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mairas
          wrote on 25 Nov 2010, 10:51 last edited by
          #4

          I haven't tested it myself, but according to the documentation, loadFromData should do exactly what you want. If it doesn't, it's a bug that should really be reported.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lbordier
            wrote on 25 Nov 2010, 12:48 last edited by
            #5

            I think i don't use it properly because with PyQt and the following code :

            from PyQt4 import QtGui

            fid = open('/tmp/buffer.out','r')
            stringBuffer = fid.read()
            fid.close()

            img1 = QtGui.QImage(640,440, QtGui.QImage.Format_ARGB32)
            img1.loadFromData(stringBuffer)

            img1.save('test_pyqt4_1.png',format='png')

            --> this make an empty png file*

            img2 = QtGui.QImage(stringBuffer,640,440, QtGui.QImage.Format_ARGB32)

            img2.save('test_pyqt4_2.png',format='png')

            --> this make a good png file with my figure

            Any idea how to use loadFromData in the good way so that i can reproduce with pyside??

            1 Reply Last reply
            0

            3/5

            25 Nov 2010, 09:21

            • Login

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