'How to set dynamic image path in pyqt5?
Here is my code:
def setimage(self):
self.image_label.setAutoFillBackground(True)
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'insert image', r'C:\Users\PristineSofts\Demo\Images','image (*.jpg *.png *.icon *.gif)')
print(filename)
self.image_label.setStyleSheet("QLabel{border:2px solid #d6d6d6;\n"
"background-image:url(" +filename+ ");\n"
"border-radius:30px;}\n")
I am trying to set image on label dynamically, but this code is not working for me. It shows path in the filename correctly, but it shows blank and window gets closed. I also used QPixmap but it not working.
Can anyone help me?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
