在插入一行数据时,需要事先对表格设置表格显示的总数:
self.tableWidget.setRowCount(10)
之后,再循环插入数据:
def after_list_devices(self, data):
row = 0
self.tableWidget.setRowCount(10)
for item in data['devices']:
self.setTableItem(row, 0, item['device_id'])
self.setTableItem(row, 1, item['device_name'])
self.setTableItem(row, 2, item['product_name'])
self.setTableItem(row, 3, item['status'])
self.setTableItem(row, 4, item['description'])
row += 1
标签:setTableItem,表格,self,PyQt5,item,数据,row
From: https://www.cnblogs.com/Himmelbleu/p/17496153.html