PyQt5 QTableWidget添加全选框

本文介绍了如何在PyQt5的QTableWidget中添加全选框功能。通过自定义QTable类,并设置相关样式和事件处理,实现了在表格中选择全部项的功能。
摘要由CSDN通过智能技术生成

作者 – 杨小名

from PyQt5.QtWidgets import (QTableWidget,QCheckBox,QHeaderView,QAbstractItemView,QTableWidgetItem,
QPushButton)
from PyQt5.QtCore import Qt,QSize,QPoint,QRect
from PyQt5.QtGui import QIcon,QMouseEvent,QFont,QColor,QBrush
from views.sys_set import readJson

class QTable(QTableWidget):
all_checkbox = []
def init(self,x=1,y=5):
super(QTable,self).init(x,y) # 默认1行 5列 第一行为表头
self.setTableStyle()

def setTableStyle(self):
    self.horizontalHeader().resizeSection(0, 100)
    self.horizontalHeader().resizeSection(1, 100)
    self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
    self.horizontalHeader().setSectionResizeMode(0, QHeaderView.Interactive)
    self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Interactive)
    self.horizontalHeader().setSectionResizeMode(2, QHeaderView.Interactive)
    self.horizontalHead
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值