《项目创建状态栏》PPT课件.ppt

上传人:w****2 文档编号:6263804 上传时间:2020-02-21 格式:PPT 页数:16 大小:907KB
返回 下载 相关 举报
《项目创建状态栏》PPT课件.ppt_第1页
第1页 / 共16页
《项目创建状态栏》PPT课件.ppt_第2页
第2页 / 共16页
《项目创建状态栏》PPT课件.ppt_第3页
第3页 / 共16页
点击查看更多>>
资源描述
创建状态栏 教师 孔祥艳 学习目标 学会创建状态栏 实验目的 在上一个实验中 我们已经设计出了一个有菜单栏 菜单和快捷键的主窗口部件 这次实验我们将在上一个实验的基础上 进一部完善窗口风格的部件 添加状态栏 实验过程 1 我们在mainwindow h中做一下更改 文件包含 include加入私有变量和函数 QLabel first statusLabel 声明两个标签对象 用于显示状态信息QLabel second statusLabel voidinit statusBar 初始化状态栏加入一个槽函数声明 voiddo cursorChanged 获取光标位置信息 2020 2 21 4 2 在mainwindow cpp中加入状态栏初始化函数的定义 voidMainWindow init statusBar QStatusBar bar ui statusBar 获取状态栏first statusLabel newQLabel 新建标签first statusLabel setMinimumSize 150 20 设置标签最小尺寸first statusLabel setFrameShape QFrame WinPanel 设置标签形状first statusLabel setFrameShadow QFrame Sunken 设置标签阴影second statusLabel newQLabel 2020 2 21 5 second statusLabel setMinimumSize 150 20 second statusLabel setFrameShape QFrame WinPanel second statusLabel setFrameShadow QFrame Sunken bar addWidget first statusLabel bar addWidget second statusLabel first statusLabel setText tr 欢迎使用文本编辑器 初始化内容second statusLabel setText tr yafeilinux制作 2020 2 21 6 3 在构造函数里调用状态栏初始化函数 init statusBar 2020 2 21 7 4 在mainwindow cpp中加入获取光标位置的函数的定义voidMainWindow do cursorChanged introwNum ui textEdit document blockCount 获取光标所在行的行号constQTextCursorcursor ui textEdit textCursor 2020 2 21 8 intcolNum cursor columnNumber 获取光标所在列的列号first statusLabel setText tr 1行 2列 arg rowNum arg colNum 在状态栏显示光标位置 这个函数可获取文本编辑框中光标的位置 并显示在状态栏中 5 在构造函数添加光标位置改变信号的关联 connect ui textEdit SIGNAL cursorPositionChanged this SLOT do cursorChanged 2020 2 21 10 6 在do file Load函数的最后添加下面语句 second statusLabel setText tr 打开文件成功 2020 2 21 11 7 在saveFile函数的最后添加以下语句 second statusLabel setText tr 保存文件成功 2020 2 21 12 8 在on action Find triggered函数的后面添加如下语句 second statusLabel setText tr 正在进行查找 2020 2 21 13 9 在on action Close triggered函数最后添加如下语句 first statusLabel setText tr 文本编辑器已关闭 second statusLabel setText tr yafeilinux制作 2020 2 21 14 实验小结 本实验在上一个实验的基础上 添加了一个窗口应用程序常用的元素 状态栏 应该来说 几乎所有的复杂一点的应用程序的界面都会设计到这个元素 本次实验简单起见 只是添加了简单的状态栏 但是基本框架已经建立起来 用户可以沿这这个思路继续丰富自己的程序 谢谢
展开阅读全文
相关资源
相关搜索

当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!