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.

Recommended Today

The use of progressbarcontrol, a progress bar control of devexpress – Taking ZedGraph as an example to add curve progress

scene WinForm control – devexpress18 download installation registration and use in vs: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100061243 When using ZedGraph to add curves, the number of curves is slower if there are many cases. So in the process of adding curve, the progress needs to be displayed, and the effect is as follows     Note: Blog home page:https://blog.csdn.net/badao_liumang_qizhi […]