PyQt5 QTable插入图片并动态更新的实例
作者:maozexijr 时间:2022-02-11 03:22:43
方式一:图片+文字
row = 0 # 行号
col = 1 # 列号
icon = QTableWidgetItem(QIcon("../image/a.png"), "Waiting") # 图片+文字
self.tblName.setItem(row, col, icon) # self → Ui_form
# 动态刷新,整个方法必须放在主线程内,自启线程无效果
QApplication.processEvents()
示例:
方式二:只有图片的
label = QLabel("")
label.setAlignment(Qt.AlignCenter) # 水平居中
# 不要使用背景透明的图片,否则多图层层叠显示
label.setPixmap(QPixmap("../image/b.png").scaled(20, 20)) # 只有图片
self.tblName.setCellWidget(row, col, label) # self → Ui_form
# 动态刷新,整个方法必须放在主线程内,自启线程无效果
QApplication.processEvents()
示例:
来源:https://blog.csdn.net/MAOZEXIJR/article/details/80888110
标签:PyQt5,QTable,图片,更新
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
新Orcas语言特性:扩展方法
2007-09-23 12:49:00
![](https://img.aspxhome.com/file/uploadpic/20079/23/200792312539649.jpg)
python编写接口测试文档(以豆瓣搜索为例)
2023-09-21 17:39:49
![](https://img.aspxhome.com/file/2023/2/62282_0s.png)
如何利用python 读取配置文件
2023-11-08 14:40:21
![](https://img.aspxhome.com/file/2023/4/83814_0s.png)
Python中你所不知道的星号 * 用法
2022-08-06 15:25:43
python实习总结(yeild,async,azwait和协程)
2021-06-16 20:40:45
Python还能这么玩之用Python修改了班花的开机密码
2023-11-23 17:38:40
![](https://img.aspxhome.com/file/2023/8/93808_0s.png)
Python生成rsa密钥对操作示例
2021-08-25 03:43:31
Python网络爬虫信息提取mooc代码实例
2022-01-02 12:18:23
发个js从样式表取值的函数
2008-05-20 12:23:00
Python创建文件和追加文件内容实例
2021-03-15 04:38:09
使用keras根据层名称来初始化网络
2021-12-09 10:51:40
pycharm不以pytest方式运行,想要切换回普通模式运行的操作
2022-02-05 15:27:10
![](https://img.aspxhome.com/file/2023/7/104817_0s.jpg)
pycharm永久激活方法
2021-12-22 01:17:34
![](https://img.aspxhome.com/file/2023/6/89216_0s.png)
Python base64和hashlib模块及用法详解
2022-09-27 14:36:17
![](https://img.aspxhome.com/file/2023/8/77548_0s.png)
如何快速通过XSL转换XML文件
2023-07-02 21:22:40
Python数据分析 Numpy 的使用方法
2023-01-14 15:12:36
Python批量查询关键词微信指数实例方法
2022-06-28 14:54:20
![](https://img.aspxhome.com/file/2023/8/93738_0s.png)
利用Django-environ如何区分不同环境
2022-01-10 10:52:24
Django配置MySQL数据库的完整步骤
2023-07-19 14:43:47
![](https://img.aspxhome.com/file/2023/9/64249_0s.png)
PyTorch搭建ANN实现时间序列风速预测
2022-11-28 23:38:28
![](https://img.aspxhome.com/file/2023/4/75364_0s.png)