"""
清理项数,表头不会清除
"""
self.tableWidget_2.setRowCount(0)
self.tableWidget_2.clearContents()
QApplication.processEvents()
"""
添加行
"""
def additem(self, row, column, text):
it = self.tableWidget_2.item(row, column)
if it is None:
currow = self.tableWidget_2.rowCount()
if currow <= row:
self.tableWidget_2.insertRow(row)
it = QtWidgets.QTableWidgetItem()
self.tableWidget_2.setItem(row, column, it)
it.setText(text)
QApplication.processEvents()
"""
设置单元格背景
"""
self.tableWidget_2.item(row, 7).setBackground(QBrush(QColor(158, 0, 0)))
QApplication.processEvents()