当前位置:网站首页>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_())

边栏推荐
- Koa koa-combine-routers 分路由管理
- Principes de formation de la programmation robotique
- 用Steam教育启发学生多元化思维
- Metauniverse and virtual reality (II)
- K210工地安全帽
- [leetcode] climb stairs [70]
- Parity linked list [two general directions of linked list operation]
- About vctk datasets
- How to do the performance pressure test of "Health Code"
- Opencv basic operation 2 realizes label2rgb and converts gray-scale images into color images
猜你喜欢

机器人编程的培训学科类原理

Windows环境下安装MongoDB数据库

Dx-11q signal relay

XJY-220/43AC220V静态信号继电器

【go】go 实现行专列 将集合进行转列

Golang treasure house recommendation

Service

New content violation degree determination scana bad information monitoring capability update issue 5

The longest selling mobile phone in China has been selling well since its launch, crushing iphone12

5. TPM module initialization
随机推荐
Service
Locking relay ydb-100, 100V
MFC TCP通信服务端客户端Demo备忘vs2019
Analyze the maker education path integrating the essence of discipline
Why not two or four TCP handshakes
Solve idea:class' xxx 'not found in module' xxx‘
2021电赛F题openmv和K210调用openmv api巡线,完全开源。
集群与LVS介绍及原理解析
StrictMode卡顿与泄漏检测-StrictMode原理(2)
双位置继电器ST2-2L/AC220V
[go] go implements row column conversion of sets
Training discipline principle of robot programming
Note d'étude du DC: zéro dans le chapitre officiel - - Aperçu et introduction du processus de base
Golang treasure house recommendation
【go】go 实现行专列 将集合进行转列
Hoo research | coinwave production - nym: building the next generation privacy infrastructure
人穷志不短,穷学生也能玩转树莓派
Dls-42/6-4 dc110v double position relay
User defined annotation implementation verification
Split the linked list [take next first and then cut the linked list to prevent chain breakage]