pyqt5 单元格
設(shè)置單元格字體和顏色
import sys from PyQt5.QtWidgets import QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem from PyQt5.QtGui import QBrush, QColor, QFont class CellFontAndColor(QWidget):def __init__(self):super(CellFontAndColor,self).__init__()self.initUI()def initUI(self):self.setWindowTitle("設(shè)置單元格字體和顏色")self.resize(430, 230);layout = QHBoxLayout()tableWidget = QTableWidget()tableWidget.setRowCount(4)tableWidget.setColumnCount(3)layout.addWidget(tableWidget)tableWidget.setHorizontalHeaderLabels(['姓名', '性別', '體重(kg)'])newItem = QTableWidgetItem('雷神')newItem.setFont(QFont('Times',14,QFont.Black))newItem.setForeground(QBrush(QColor(255,0,0)))tableWidget.setItem(0,0,newItem)newItem = QTableWidgetItem('女')newItem.setForeground(QBrush(QCo總結(jié)
- 上一篇: Pyqt5表格
- 下一篇: opencv图像处理(二)