当前位置:网站首页>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_())
边栏推荐
- StrictMode分析Activity泄漏-StrictMode原理(3)
- Open3D 点云包围盒
- Technical personnel advanced to draw a big picture of business, hand-in-hand teaching is coming
- DC学习笔记正式篇之零——综述与基本流程介绍
- 解读创客教育所蕴含的科技素养
- Exploration and practice of "flow batch integration" in JD
- pull_ to_ refresh
- Call the classic architecture and build the model based on the classic
- 06.论Redis持久化的几种方式
- 一些本质的区别
猜你喜欢
随机推荐
StrictMode带来的思考-StrictMode原理(5)
Typora的使用
Split the linked list [take next first and then cut the linked list to prevent chain breakage]
双位置继电器DLS-5/2 DC220V
js中把数字转换成汉字输出
人穷志不短,穷学生也能玩转树莓派
文件服务设计
Golang treasure house recommendation
Green, green the reed. dew and frost gleam.
探索互联网时代STEAM教育创新之路
Pre training / transfer learning of models
06.论Redis持久化的几种方式
WIN11中MathType编辑中“打开数学输入面板”是灰色不可编辑
fluttertoast
Orb-slam2 source code learning (II) map initialization
Introduction and principle analysis of cluster and LVS
Opencv basic operation 2 realizes label2rgb and converts gray-scale images into color images
Dx-11q signal relay
ASCII、Unicode、GBK、UTF-8之间的关系
DC学习笔记正式篇之零——综述与基本流程介绍