st.img.save('./test.png', 'PNG')
img = Image.open('./test.png')
self.imgQ = ImageQt(img)
pixMap = QPixmap.fromImage(self.imgQ)
这里显示typeError:
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)
我认为ImageQt
会将Image
转换为QImage
。谁能告诉我如何解决这个问题?
答案 0 :(得分:2)
ImageQt
模块包含QImage
的子类,它从PyQt
导入,而不是PySide
。
为了让ImageQt
使用PySide
,您可以尝试一下这样的黑客攻击:
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