PySide compared to PyQt4 : problem with QImage __init__()



  • 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.



  • 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.



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



  • 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.



  • 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??


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.