# Form implementation generated from reading ui file 'cc.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
# Form implementation generated from reading ui file 'connect_me.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
#导入程序运行必须模块
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QColor, QBrush
from cc import Ui_widget
class MyMainForm(QMainWindow, Ui_widget):
def __init__(self, parent=None):
super(MyMainForm, self).__init__(parent)
self.setupUi(self)
for i in range(len(items)):
item = items
row = self.tableWidget.rowCount()
self.tableWidget.insertRow(row)
for j in range(len(item)):
item = QTableWidgetItem(str(items[j]))
self.tableWidget.setItem(row,j,item)
复制代码
运行结果如下: (, 下载次数: 0)
上传
点击文件名下载附件
(6) 设置表格标题字体加粗。添加代码如下:
font = self.tableWidget.horizontalHeader().font()
font.setBold(True)
self.tableWidget.horizontalHeader().setFont(font)
运行效果如下
# Form implementation generated from reading ui file 'connect_me.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
#导入程序运行必须模块
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QColor, QBrush
from PyQt5.QtCore import Qt
from cc import Ui_widget