其他分享
首页 > 其他分享> > QTableWidget

QTableWidget

作者:互联网

"""
清理项数,表头不会清除
"""
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()

标签:column,processEvents,self,QTableWidget,QApplication,tableWidget,row
来源: https://www.cnblogs.com/archer-mowei/p/15709616.html