0
st.img.save('./test.png', 'PNG')
img = Image.open('./test.png')
self.imgQ = ImageQt(img)
pixMap = QPixmap.fromImage(self.imgQ)

It shows typeError here:

    pixMap = QPixmap.fromImage(self.imgQ)
TypeError: 'PySide.QtGui.QPixmap.fromImage' called with wrong argument types:
  PySide.QtGui.QPixmap.fromImage(ImageQt)
Supported signatures:
  PySide.QtGui.QPixmap.fromImage(PySide.QtGui.QImage, PySide.QtCore.Qt.ImageConversionFlags = Qt.AutoColor)

I think the ImageQt would convert the Image to QImage. Can anyone tell me how to solve this?

1 Answer 1

2

The ImageQt module contains a subclass of QImage, which it imports from PyQt, not PySide.

In order to get ImageQt to use PySide, you could try a little hack, like this:

import sys
from PySide import QtGui
sys.modules['PyQt4.QtGui'] = QtGui
# or if you have PyQt5 installed, you might need this
# sys.modules['PyQt5.QtGui'] = QtGui
from PIL import ImageQt
2
  • Thanks! it solves my problem! By the way, I met another problem. one of the image Shown in QGraphicsview is distorted. Do you know the possibly reason? It's okay if you don't want to answer this question.
    – BadEggX
    Dec 7, 2014 at 7:16
  • @BadEggX. I don't the answer from your description. Perhaps you should post anther question with more information.
    – ekhumoro
    Dec 7, 2014 at 17:05

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.