I am using Pyqt5, python3.9, and windows 11. I am trying to add an image to my app but it wont display anything as show below.
from PyQt5 import QtCore, QtGui, QtWidgetsclass Ui_Dialog(object):def setupUi(self, Dialog):Dialog.setObjectName("Dialog")Dialog.resize(531, 316)self.label = QtWidgets.QLabel(Dialog)self.label.setGeometry(QtCore.QRect(70, 30, 491, 241))self.label.setText("")self.label.setPixmap(QtGui.QPixmap(":/newPrefix/download.png"))self.label.setObjectName("label")self.retranslateUi(Dialog)QtCore.QMetaObject.connectSlotsByName(Dialog)def retranslateUi(self, Dialog):_translate = QtCore.QCoreApplication.translateDialog.setWindowTitle(_translate("Dialog", "Dialog"))if __name__ == "__main__":import sysapp = QtWidgets.QApplication(sys.argv)Dialog = QtWidgets.QDialog()ui = Ui_Dialog()ui.setupUi(Dialog)Dialog.show()sys.exit(app.exec_())][1]
My Application:
This is my qrc file:
<RCC><qresource prefix="newPrefix"><file>download.png</file><file>background.gif</file></qresource>
</RCC>
And both the image and the main.py are in the same directory. Any idea why this does not work?
EDIT: The code seems to work on windows 10 but not on windows 11.