




已阅读5页,还剩77页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
毕业设计说明书基于QT的记事本和电子相册 学生姓名: 学号: 学 院: 专 业: 指导教师: 2014年6月基于QT的记事本和电子相册摘 要越来越多的设备需要一个图形化的人机接口界面(GUI),良好的人机交互界面是各个软件系统设计的一个关键技术,尤其是在给广大人们的使用中,对程序的实用性、美观性和视听娱乐性提出了更高的要求。而记事本和电子相册以其实用性和良好的观赏性逐渐成为人们查看和使用中不可或缺的组成部分。开发基于Qt的界面美观、功能丰富的记事本和电子相册,具有一定的实用意义和价值。本文的目标是设计和实现基于Qt的记事本和电子相册。论文首先介绍了Qt的优点和Qt开发环境的搭建,着重分析了Qt在软件开发中的编程机制。并根据嵌入式应用的特点对基于Qt的记事本和电子相册进行了设计需求分析、具体界面的设计和整体结构的设计。本课题根据记事本和电子相册的算法,设计并实现了记事本的相关功能(如:新建、打开、编辑和删除文件等)和电子相册的相关功能。最后对关于论文进一步工作的方向进行了简要的讨论。关键字: Qt, 图形用户界面, 记事本,电子相册Embedded terminal application program development based on QTDevelopment of notepad and electronic albumAbstractMore and more embbeded Embedded Terminal need graphics user interface(GUI). A good Human-Computer Interaction interface is the key technology of embedded system design. Higher demands of the practicality, aesthetics and audio-visual entertainment of embedded terminal are needed, especially in embbeded system handheld device. Notepad and electronic photo album are becoming an integral part of embedded device for their pracicality and good viewing. It has some practical significance and value to develop a notepad and an album with beautiful interface, rich functions and good interaction based on embedded terminal.The aim of this paper is to design and implement a notepad and an album in the embeded terminal environment. This paper presented the advantage of Linux and the building of QT developing environment, focused on the programming mechanism of developing software with Qt. It analysed the needs of the design, designed the specific interface and overall structure of notepad and album in the embeded terminal environment according to features of embedded application.This project designed and implemented the relevant functions of norepad(such as new file,open file ,edit file and delete file) as well as the relevant functions of album(such as enlarge 、minify、 rotate and move the picture) based on the algorithms of notepad and album. Finally, brief disscusion about the further reaserch of this paper was presented.Key words:Qt,GUI,notepad,albtextEdit-clear(); setCurrentFile(); /判断是否选择保存内容bool Test:maybeSave() if (ui-textEdit-document()-isModified() QMessageBox:StandardButton ret; ret = QMessageBox:warning(this, tr(Application), tr(The document has been modified.n Do you want to save your changes?), QMessageBox:Save | QMessageBox:Discard | QMessageBox:Cancel); if (ret = QMessageBox:Save) qDebug()2; return save(); else if (ret = QMessageBox:Cancel) qDebug()3; return false; return true;/保存内容 如果原先不存在 则跳转到saveAs()弹出对话框进行保存 如果存在则使用当前的路径bool Test:save() if (curFile.isEmpty() return saveAs(); else qDebug()6; return saveFile(curFile); /弹出保存的对话框bool Test:saveAs() QString fileName = QFileDialog:getSaveFileName(this,tr(请确定),/,*.txt); qDebug()fileName; if (fileName.isEmpty() qDebug()7; return false; qDebug()8; return saveFile(fileName+.txt);bool Test:saveFile(const QString &fileName) QFile file(fileName); /qDebug()fileN; if (!file.open(QFile:WriteOnly | QFile:Text) QMessageBox:warning(this, tr(Application), tr(Cannot write file %1:n%2.) .arg(fileName) .arg(file.errorString(); return false; QTextStream out(&file); out textEdit-toPlainText(); setCurrentFile(fileName); ui-label-setText(tr(File saved); qDebug()textEdit-document()-setModified(false); setWindowModified(false); QString shownName = curFile; if (curFile.isEmpty() shownName = wangrui.txt; setWindowFilePath(shownName); /打开文件void Test:openFile() if (maybeSave() QString fileName = QFileDialog:getOpenFileName(this,tr(请选择),/,*.txt); if (!fileName.isEmpty() loadFile(fileName); void Test:loadFile(const QString &fileName) QFile file(fileName); if (!file.open(QFile:ReadOnly | QFile:Text) QMessageBox:warning(this, tr(Application), tr(Cannot read file %1:n%2.) .arg(fileName) .arg(file.errorString(); return; QTextStream in(&file); ui-textEdit-setPlainText(in.readAll(); setCurrentFile(fileName); ui-label-setText(tr(File loaded);void Test:about() QMessageBox:about(this, tr(About Application), tr(This Project is made by WangRui);void Test:back() this-hide(); MainWindow *mw=new MainWindow; mw-show();void Test:time() QDateTime current_date_time = QDateTime:currentDateTime(); QString current_date = current_date_time.toString(yyyy-MM-dd hh:mm:ss ddd); ui-label_2-setText(current_date);void Test:find()/查找 QDialog *findDlg=new QDialog(this); findDlg-setWindowTitle(tr(查找); find_textLineEdit=new QLineEdit(findDlg); QPushButton *find_Bth=new QPushButton(tr(查找下一个),findDlg); QHBoxLayout *layout=new QHBoxLayout(findDlg); layout-addWidget(find_textLineEdit); layout-addWidget(find_Bth); findDlg-show(); connect(find_Bth,SIGNAL(clicked(),this,SLOT(show_findText(); void Test:show_findText() QString findText=find_textLineEdit-text(); if(!ui-textEdit-find(findText,QTextDocument:FindBackward) QMessageBox:warning(this,tr(查找),tr(找不到 %1).arg(findText); 4.2 电子相册主要算法设计和实现4.2.1 电子相册类结构设计图4.2 电子相册类图4.2.2 电子相册功能实现(1) 用户进入电子相册后,首先需要点打开按钮选择文件夹中的照片。图片由imageList存放,将从当前目录下得到jpg、xpm、png、gif、bmp格式的图片存入链表中,通过load函数加载图片到一个QPixmap类型的变量中,然后将此变量与Label关联起来,以实现图片在Label上的显示。值得注意的一点是,此Label上加载的图片均为真实图片的缩略图,而不是图片本身。如果图片的缩略图已经存在,则将缩略图直接显示在Label上,如果缩略图不存在,则生成图片的缩略图。如果该图片文件为非法图片格式文件,则在该Label上载入一个标志着读取图片文件失败的图片。缩略图是图片的真实缩影,在刚打开图片显示时保持原图片的比例。(2) 删除图片功能实现:在对当前图片界面上要进行删除操作时,需注意两点,一点就是待删除的图片是否是图片列表的最后一张图片,若是的话,则删除图片后,被删除图片的前一张图片呈现出在显示图片界面上。否则,删除图片后,被删除图片的后一张呈现在显示图片界面上,且此图片删除后,图片文件链表中删除图片节点,其列表界面中图片的位置要统一向前移动一个位置(3) 图片的放大功能的实现:设定scaleImag()来记录放大的倍数,并且当放大到最大倍数时,将菜单项上的“放大”按钮变成不可点击的状态,并且根据放大倍数在浏览区域的相框上绘制图片。(4) 图片缩小功能的实现:可在图片的任意大小状态下进行缩小,直到图片缩小到初始打开图片显示尺寸的0.333倍大小。缩小图片时要保证缩小后的图片依然居于相框中间位置。在图片非全屏模式和全屏模式两种情况下,判定当前状态的图片与初始时显示的位置移动的距离大小,并根据不同的图片旋转角度,据此距离大小计算并设定相应的图片在相框中的位置坐标。(5) 图片移动功能实现:图片在放大到1.0倍以上时,可进行图片在相框内的上下或左右移动显示。图片在全屏模式下选择放大时图片也可以进行上下或左右移动显示。(6) 相框内图片显示功能的实现:不同的选择下,相框内的图片显示状态是不同的。对于图片的显示需要考虑的情况有是否是全屏模式,当前的缩放倍数和当前的旋转角度,并需要根据判断图片是否移动来对显示边界进行检测及计算。根据图片缩放和旋转参数和检测到的移动距离,利用矩阵计算出新图片所需的各个参数,根据这些参数生成显示在相框内的图片。最后将图片绘制在相框内,即当前的图片浏览区内。4.2.3 电子相册代码实现void ImageShow:scaleImage(double factor) scaleFactor *= factor; imageLabel-resize(scaleFactor * imageLabel-pixmap()-size(); adjustScrollBar(scrollArea-horizontalScrollBar(), factor); adjustScrollBar(scrollArea-verticalScrollBar(), factor); ui-actionBig-setEnabled(scaleFactor actionSmall-setEnabled(scaleFactor 0.333);void ImageShow:adjustScrollBar(QScrollBar *scrollBar, double factor) /qDebug()setValue(int(factor * scrollBar-value() + (factor - 1) * scrollBar-pageStep()/2);void ImageShow:fangDa() scaleImage(1.25);void ImageShow:suoXiao() scaleImage(0.8);void ImageShow:fitToWindow() scrollArea-setWidgetResizable(true); ui-actionBig-setEnabled(false); ui-actionSmall-setEnabled(false); ui-actionOpen-setEnabled(false);void ImageShow:normal() scrollArea-setWidgetResizable(false); ui-actionBig-setEnabled(true); ui-actionSmall-setEnabled(true); ui-actionOpen-setEnabled(true); imageLabel-adjustSize(); scaleFactor = 1.0;/控件的失效与否void ImageShow:hideView(bool b) ui-actionFitToWindow-setEnabled(b); ui-actionBig-setEnabled(b); ui-actionSmall-setEnabled(b); ui-actionNormal-setEnabled(b); ui-actionXuanZuan-setEnabled(b); ui-actionDown-setEnabled(b); ui-actionUpper-setEnabled(b); ui-actionBegin-setEnabled(b); ui-actionStop-setEnabled(b); ui-actionDelete-setEnabled(b);/使图片旋转90度void ImageShow:xuanZuan() QMatrix matrix; matrix.rotate(90.0); pix=pix.transformed( matrix,Qt:FastTransformation); imageLabel-setPixmap(pix);/打开图片void ImageShow:open() int k = 0; QStringList list = QFileDialog:getOpenFileNames(this,tr(请选择),/,*.png *.jpg *.gif *.xpm *.bmp); for(it = list.begin();it actionNumber-setText(tr(%1 / %2).arg(image_positon).arg(image_sum); pix.load(imageListi); imageLabel-setPixmap(pix); scaleFactor = 1.0; imageLabel-adjustSize(); hideView(true); ui-actionStop-setEnabled(fal
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 诚信培训考试试题及答案
- 走进森林 测试题及答案
- 育婴师考试知识点的网络学习方法试题及答案
- 药剂学教育模式探讨试题及答案
- 北京市徐悲鸿中学2025年高三学情摸底物理试题
- 高效备考卫生管理试题及答案
- 人工智能驱动人形机器人技术革新
- 赋能2025年育婴师考试准备试题及答案
- 2025年汽车安全气囊及装置项目合作计划书
- 腾讯软件笔试题库及答案
- 2024年广东省中考历史试卷试题真题及答案(精校打印版)
- JJG 705-2014液相色谱仪行业标准
- YY/T 0331-2024脱脂棉纱布、脱脂棉粘胶混纺纱布的性能要求和试验方法
- 计划书绿色背景
- 北师大版数学三年级下册-第3单元《找规律》教案
- 西安市西绕城高速路上桥群机械拆除工程施工方案样本
- 中国商飞公司招聘笔试题
- 《含能材料与应用》课件
- 土地管理法实施条例考试试题
- 真实的PBL真实的挑战:项目式学习设计指南
- 水果批发市场项目商业计划书
评论
0/150
提交评论