Issue
i am working on project works with QR Images and i have to convert a link into a qr image
after that i have to show the image on the window.
i am using qrcode library and it provides a way to convert the image into QImage, and i can set it directly on the window without save it as a file after that read it.
and i do not want to save it as a file , only i want to read it.
but when i tried to do it i got an error.
this is a code for test :
from PyQt5 import QtWidgets
from PyQt5 import QtGui
import sys
import qrcode
qr_coda_as_an_image = qrcode.make("Link")
qr_coda_as_an_image = qr_coda_as_an_image.get_image()
qr_coda_as_an_image = qr_coda_as_an_image.toqimage()
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
window.resize(800,500)
window_layout = QtWidgets.QGridLayout()
image = QtGui.QPixmap.fromImage(qr_coda_as_an_image)
first_widget = QtWidgets.QLabel()
first_widget.setPixmap(image)
window_layout.addWidget(first_widget)
window.setLayout(window_layout)
window.show()
app.exec()
it was working when i made it but after a few edits i broke it , and i have been trying for 5 hours to find the problem or to solve it but i failed.
this is the error :
TypeError: fromImage(QImage, flags: Union[Qt.ImageConversionFlags, Qt.ImageConversionFlag] = Qt.AutoColor): argument 1 has unexpected type 'ImageQt'
thanks
Solution
The problem was in the environment of python, the code was working and i updated the PIL and because of that it is not working.
the solution is to uninstall the PIL after that install PIL == 9.1.1.
because like the user ekhumoro said that PIL does not support the PyQt5 anymore.
thanks
Answered By - Mohammed almalki
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.