I have problem with insert image from url to cell in tablewidget pyqt5 in python . I want show image in cell. You can see my table on the image from attachments. When i use my code (below) i do not get anything (zero images) in my cell.Please show me way to do this.
# sample link with image i use from loop:
#https://a.allegroimg.com/original/037495/be1ecbef43e7a2039a0bc42ceddf.jpg
zdi2 = 'https://a.allegroimg.com/original/037495/be1ecbef43e7a2039a0bc42ceddf.jpg'
data = urllib.urlopen(zdi2).read()
pixmap = QPixmap()
pixmap.loadFromData(data)
icon = QIcon(pixmap)
self.tableWidget_14.setItem(row_numer13,1,QTableWidgetItem(icon))
Problem solved. Solution is QLabel:
zdi2 = 'https://a.allegroimg.com/original/037495/be1ecbef43e7a2039a0bc42ceddf.jpg'
r = requests.get(zdi2,stream=True)
assert r.status_code == 200
img = QImage()
assert img.loadFromData(r.content)
w = QLabel()
w.setPixmap(QPixmap.fromImage(img))
w.setGeometry(0,0,5,5)
w.resize(20,20)
self.tableWidget_14.setCellWidget(row_numer13,1,w)