-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
ImageQt does not work as expected in PyQt5 #5266
Copy link
Copy link
Closed
Labels
QtQt for Python, PyQt, PySideQt for Python, PyQt, PySide
Description
What did you do?
Attempted to use ImageQt to load a Pillow image in a PyQt5 application
What did you expect to happen?
I expected the image to load correctly. There are no errors, but it does not load the image in PyQt5 correctly.
What actually happened?
The image loaded as a mostly white image with kind of ghost image of the actual photo (see screenshot). I have attached the PyQt5 and PySide6 code, including screenshots from when I ran both files.
Note: The same code works in PySide6, but not in PyQt5.
What are your OS, Python and Pillow versions?
import sys
from PIL import Image, ImageQt
from PyQt5.QtGui import QPixmap, QImage
from PyQt5.QtWidgets import QWidget, QLabel
from PyQt5.QtWidgets import QVBoxLayout, QApplication
class ImageViewer(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setWindowTitle("PyQt Image Viewer")
# Open up image in Pillow
image = Image.open("pink_flower.jpg")
qt_image = ImageQt.ImageQt(image)
pixmap = QPixmap.fromImage(qt_image)
self.image_label = QLabel('')
self.image_label.setPixmap(pixmap)
self.main_layout = QVBoxLayout()
self.main_layout.addWidget(self.image_label)
self.setLayout(self.main_layout)
if __name__ == "__main__":
app = QApplication(sys.argv)
viewer = ImageViewer()
viewer.show()
app.exec_()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
QtQt for Python, PyQt, PySideQt for Python, PyQt, PySide
