当前位置:网站首页>qt5-MVC:数据可视化的层次揭秘
qt5-MVC:数据可视化的层次揭秘
2022-07-01 00:41:00 【德天老师】
MVC模式原理
每一个程序都有其原理,我们学习过程中透过他们的原理,来了解他们的工作方向,将会使我们的学习变得无比简单。
揭秘数据层次顺序
- 建立格式布局
- 调用可视化功能
- 建立字符型列表模型
- 定义列表源数据列
- 把数据源列表加入列表模型
- 把列表模型加入可视化功能(可视化点击发射信号–激活消息盒子)
- 消息盒子槽函数,相当于列数数据的功能交互,完成数据消息功能调试
- 将可视化加入布局,相当于摆放到窗口内部
- 激活可视化布局,相当于把数据这块牌匾上面的红布揭开,正式对公众宣传开业。
消息槽函数
def clicked(self,item):
QMessageBox.information()—消息盒子
参数1:继承父类self
参数2:QListView—触发继承自QListView
参数3:盒子信息,信号列表索引item.row()
备注:
item—是列表的内容
.row()—是调用当前内容的显示行索引(0,1,2…)
程序源码
from PyQt5.Qt import *
import sys
app = QApplication([])
class ListView(QWidget):
def __init__(self,parent=None):
super(ListView,self).__init__(parent)
self.setWindowTitle('QListView 例子')
self.resize(300,270)
layout = QVBoxLayout()
listview = QListView()
listmodel = QStringListModel()#字符列表:针对列表显示模型
self.list = ['列表1','列表2','列表3']
listmodel.setStringList(self.list)
listview.setModel(listmodel)
listview.clicked.connect(self.clicked) #发射一个item.row()索引数据给self.clicked
layout.addWidget(listview)
self.setLayout(layout) #布局生效语句,必须写完整,否则添加的可视化模板无法显示
#点击弹出消息盒子,单击每一个列表项会有一个值存储到槽函数item中,item.row()方法会把对应项的索引数据显示出来
def clicked(self,item):
QMessageBox.information(self,'QListView','您选择了'+self.list[item.row()])
win = ListView()
win.show()
sys.exit(app.exec_())

边栏推荐
- 解析融合学科本质的创客教育路径
- [leetcode] sum of two numbers [1]
- 06. on several ways of redis persistence
- 关于Unity一般的输入操作方式
- 尝试新的可能
- StrictMode卡顿与泄漏检测-StrictMode原理(2)
- Introduction and principle analysis of cluster and LVS
- DLS-20型双位置继电器 220VDC
- Interpreting the scientific and technological literacy contained in maker Education
- 【学习笔记】构造
猜你喜欢

Docker 部署 MySQL 8

Introduction and principle analysis of cluster and LVS
![[go] go implements row column conversion of sets](/img/d9/6272e55b2d9c6b6fbdf2537773bb83.png)
[go] go implements row column conversion of sets

解析创客教育实践中的智慧原理

基础知识之三——标准单元库
![分割链表[先取next再斩断链表防止断链]](/img/eb/708ab20c13df75f4dbd2d6461d3602.png)
分割链表[先取next再斩断链表防止断链]

友盟(软件异常实时监听的好帮手:Crash)接入教程(有点基础的小白最易学的教程)

技术人进阶画业务大图,手把手教学来了

Call the classic architecture and build the model based on the classic

Practical shell knowledge
随机推荐
uniapp官方组件点击item无效,解决方案
Hoo research | coinwave production - nym: building the next generation privacy infrastructure
How to do the performance pressure test of "Health Code"
解析融合学科本质的创客教育路径
闭锁继电器YDB-100、100V
【学习笔记】构造
二季度最后一天
分割链表[先取next再斩断链表防止断链]
Pre training / transfer learning of models
友盟(软件异常实时监听的好帮手:Crash)接入教程(有点基础的小白最易学的教程)
[leetcode] climb stairs [70]
双位置继电器DLS-5/2 DC220V
Principes de formation de la programmation robotique
Kongyiji's first question: how much do you know about service communication?
Win11安装redis 数据库以及redis desktop manager的下载
图的连通性基础
Parity linked list [two general directions of linked list operation]
Solve idea:class' xxx 'not found in module' xxx‘
Vnctf 2022 cm CM1 re reproduction
Openmv and k210 of the f question of the 2021 video game call the openmv API for line patrol, which is completely open source.