创新的做pc端网站,网络推广培训哪个好,网站有哪些推荐,iis 网站目录权限设置ySide6/PyQt6的开发框架主界面支持多文档管理#xff0c;可包括菜单栏、工具栏、内容区和状态栏等#xff0c;内容区以选项卡方式展示多个窗口#xff0c;如下所示。image常规的编辑界面如用户界面#xff0c;双击列表弹出展示#xff0c;如下所示。image主从表展示界面如…ySide6/PyQt6的开发框架主界面支持多文档管理可包括菜单栏、工具栏、内容区和状态栏等内容区以选项卡方式展示多个窗口如下所示。image常规的编辑界面如用户界面双击列表弹出展示如下所示。image主从表展示界面如下所示。image主从表直接编辑界面在弹出对话框中进行编辑主表信息和明细记录明细记录通过表格方式直接录入方便各种类型的数据录入处理。1、在PySide6/PyQt6的开发框架中表格的数据录入我们先来看看测试案例查看下表格中多种格式录入的效果image视频效果如下所示如我们在产品报价单中进行主从表编辑数据的时候界面如下所示其中产品信息通过弹出自定义产品列表进行选择。image其他如产品类型、产品规格、产品型号、标准单位、产品尺寸等通过绑定系统字典类型作为下拉列表的数据源。image上面就是实际的报价单的界面录入可以通过自定义的对话框选择也可以直接录入文本还可以通过绑定字典类型获得下拉列表选择等处理操作。2、表格数据直接录入的委托类处理在PySide6/PyQt6中对于 QTableView 的定制化输入是通过继承 QStyledItemDelegate 来实现定制化的表格单元格输入或者显示的。如我们自定义类如下所示。class CustomDelegate(QStyledItemDelegate):我们让它支持的类型包括- text: 普通文本 (QLineEdit)- int: 整数 (QSpinBox)- double: 浮点数 (QDoubleSpinBox)- date: 日期 (QDateEdit)- combo: 下拉选择 (QComboBox)- check: 复选框 (直接显示)- radio: 单选按钮组 (QRadioButton)- slider: 滑动条 (QSlider)- multiline: 多行文本 (QTextEdit)- password: 密码文本 (QLineEdit)- percent: 百分比 (QDoubleSpinBox)- currency: 货币 (QDoubleSpinBox)- time: 时间 (QTimeEdit)- datetime: 日期时间 (QDateTimeEdit)- color: 颜色选择 (QPushButton)- icon: 图标选择 (QPushButton)- bitmap: 位图选择 (QPushButton)- custom: 自定义不可编辑控件同时触发 customTriggered 信号传出单元格索引和字段名称最终它的配置示例如下代码所示。config {name: {type: text},age: {type: int, min: 0, max: 120},score: {type: double, min: 0, max: 1000, decimals: 3, step: 0.01},birthday: {type: date, format: yyyy-MM-dd},tag: {type: combo, items: [选项A, 选项B, 选项C]},married: {type: check, true: 是, false: 否},gender: {type: radio, items: [男, 女, 未知], width: 180},score_2: {type: slider, min: 0, max: 100, step: 1},description: {type: multiline},password: {type: password},percent: {type: percent, min: 0, max: 100, decimals: 2, step: 0.1},currency: {type: currency, min: 0, max: 1000000, decimals: 2, step: 0.1},time: {type: time, format: HH:mm:ss},datetime: {type: datetime, format: yyyy-MM-dd HH:mm:ss},color: {type: color, format: color},icon: {type: icon, default: SP_ArrowDown},bitmap: {type: bitmap, default: bitmap.png},}view QTableView()view.setModel(model)delegate CustomDelegate(config, view)view.setItemDelegate(delegate)同时我们为了支持自定义的列表对话框选择那么我们通过触发信号来获得对应的事件处理即可如下所示。#自定义单元格编辑事件self.delegate.customTriggered.connect(self.on_custom_triggered)def on_custom_triggered(self, index: QModelIndex, field_name: str):自定义单元格编辑事件# print(fon_custom_triggered: index{index}, field_name{field_name})if field_name productno:# 弹出选择产品对话框dlg FrmProductSelect(self)if dlg.exec() QDialog.DialogCode.Accepted:info dlg.select_productif info is not None:# print(f选择的产品信息{info})row index.row()self.sub_table_model.SetValueByKey(row, productno, info.productno)# #同步更新产品名称/条形码/规格/型号/单位/颜色/尺寸等self.sub_table_model.SetValueByKey(row, productname, info.productname)....# 同步更新数量....# 同步更新金额小结....dlg.deleteLater()通过对自定义委托类中的 信号对象 customTriggered 进行监听我们就可以获得用户触发选择某个单元格的事件并可以通过弹出自定义对话框获取列表选择并把数据写回到对应单元格中即可。而对于指定系统字典类型作为下拉列表的操作我们只需要设置字段类型为combo或者radio并动态设置字典类型绑定即可。#表格单元格的编辑控件配置 动态指定字典config {orderno: {type: text},quantity: {type: int, min: 0, max: 1000},saleprice: {type: double, min: 0, decimals: 3, step: 0.01},subamout: {type: double, min: 0, decimals: 3, step: 0.01},expiredate: {type: date, format: yyyy-MM-dd},note: {type: multiline},productno: {type: custom},producttype: {type: combo},model: {type: combo},specification: {type: combo},unit: {type: combo},color: {type: combo},productsize: {type: radio},