Example of pyqt5 qtable inserting pictures and updating them dynamically

Time:2019-11-5

Mode 1: picture + text

Row = 0 × line number
Col = 1 × column No
Icon = qtablewidget item (qicon (".. / image / a.png"), "waiting") (picture + text)
self.tblName.setItem(row, col, icon) # self → Ui_form
 
#Dynamic refresh, the whole method must be placed in the main thread, and the self starting thread has no effect
QApplication.processEvents()

Example:

Mode 2: only pictures

label = QLabel("")
Label. Setalignment (QT. Aligncenter) × horizontal center
 
#Do not use pictures with transparent background, otherwise they will be displayed in layers
Label. Setpixmap (qpixmap (".. / image / B.png"). Scaled (20, 20)) (only pictures)
self.tblName.setCellWidget(row, col, label) # self → Ui_form
 
 
#Dynamic refresh, the whole method must be placed in the main thread, and the self starting thread has no effect
QApplication.processEvents()

Example:

The above example of pyqt5 qtable inserting pictures and updating dynamically is all the content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developepaer more.