基于QT的电子相册设计.docx_第1页
基于QT的电子相册设计.docx_第2页
基于QT的电子相册设计.docx_第3页
基于QT的电子相册设计.docx_第4页
基于QT的电子相册设计.docx_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于QT的电子相册设计一、设计内容及要求:1)能从存储卡中读取图像文件,并在LCD屏上显示图像文件,支持多种主流格式;2)显示时间、日期;3)通过按钮或触摸屏进行操作。二、设计目的1)了解Linux嵌入式2)了解QT的设计过程3)了解PC机和开发板之间的通信三、设计工具PC机、开发板四、设计过程1、功能模块结构架构图功能模块图片浏览模块图片播放模块系统设计模块2、具体功能模块架构图图片浏览模块图像正旋图像反旋图像放大图像缩小上一张图片下一张图片图像播放和系统设计模块选择加载图片图片播放4、基于QT的图像界面设计显示5、用户界面层代码设计#include mainwindow.h#include ui_mainwindow.hMainWindow:MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui:MainWindow) ui-setupUi(this); /init data image_sum = 0; image_index = 0; timer_second = 1000; /default 1s disp_angle = 0; disp_width = 281; disp_height = 211; disp_xratio = 1.0;disp_yratio = 1.0;/timer timer = new QTimer; /label label = new QLabel; ui-scrollArea-setWidget(label); ui-scrollArea-setAlignment(Qt:AlignCenter); /connect timout function connect(timer,SIGNAL(timeout(),this,SLOT(disp_timeout(); return;MainWindow:MainWindow() delete ui;6、用户图形界面的按钮功能实现代码void MainWindow:disp_timeout(void) image_show(); image_jump_to_next(); return;void MainWindow:image_jump_to_next() /check error if(0=image_sum) return; image_index+; if(image_index=image_sum) image_index = 0; return;void MainWindow:image_jump_to_prev() /check error if(0=image_sum) return; image_index-; if(image_index=image_sum |image_indeximage_height*disp_width) image_height *= (disp_width/(double)image_width); image_width *= (disp_width/(double)image_width); else image_width *= (disp_height/(double)image_height); image_height *= (disp_height/(double)image_height); image_width *= disp_xratio; image_height *= disp_yratio; pix = pix.scaled(image_width, image_height,Qt:KeepAspectRatio); /set image label-setPixmap(pix); return;void MainWindow:on_pushButton_add_clicked(void) long k=0; /file iterator QStringList:Iterator it; /file list QStringList list; /open dialog and add image files list = QFileDialog:getOpenFileNames(this, ,/,*.*); for(it=list.begin();itstart(timer_second); this-image_show(); return;void MainWindow:on_pushButton_stop_clicked() timer-stop(); return;void MainWindow:on_pushButton_play_clicked() timer-start();void MainWindow:on_pushButton_prev_clicked() /check error if(0 = image_sum) return; /stop display timer timer-stop();/jump to prev image image_jump_to_prev();/show image image_show(); return;void MainWindow:on_pushButton_next_clicked() /check error if(0 = image_sum) return; /stop display timer timer-stop(); /jump to next image image_jump_to_next();/show image image_show(); return;void MainWindow:on_pushButton_zoomin_clicked() disp_xratio += 0.05; disp_yratio += 0.05; image_show(); return;void MainWindow:on_pushButton_zoomout_clicked() if(disp_xratio0.05)disp_xratio -= 0.05; if(disp_yratio0.05)disp_yratio -= 0.05; image_show(); return;void MainWindow:on_pushButton_clockwise_clicked() disp_angle += 90; image_show(); return;void MainWindow:on_pushButton_anticlockwise_clicked() disp_angle -= 90; image_show(); return;7、功能模块实现代码:#include image.h#include ui_image.hint i=0;int j;/QString ima5=:/1.PNG,:/2.PNG,:/3.PNG,:/4.PNG,:/5.PNG;QString imagelist1000;QStringList:Iterator it;/迭代器的对象,类似指针但不是指针image:image(QWidget *parent) : QWidget(parent), ui(new Ui:image) ui-setupUi(this); /给窗体设置背景图片 QImage image1; image1.load(:/6.PNG); /括号内为图片的相对目录 QImage image2 = image1.scaled(320,240); QPalette palette;/定义窗口 palette.setBrush(this-backgroundRole(),QBrush(image2); this-setPalette(palette);/在定义的窗口显示 timer = new QTimer; label = new QLabel;/不报错但运行不出,头文件声明必须初始化 /matrix= new QMatrix; connect(timer,SIGNAL(timeout(),this,SLOT(imageshow(); ui-scrollArea-setWidget(label);/用scrollArea作为label的窗口 / ui-label-setAlignment(Qt:AlignCenter); ui-scrollArea-setAlignment(Qt:AlignCenter);void image:imageshow() pix.load(imagelisti); label-setPixmap(pix); i+; if(ij) i=0; image:image() delete ui;void image:on_pushButton_clicked() timer-start(1000); pix.load(imagelisti); label-setPixmap(pix); i+; if(ij) i=0; void image:on_Pause_clicked() timer-stop();void image:on_UP_clicked() timer-stop(); i+; if (i=j) i=0; pix.load(imagelisti); label-setPixmap(pix);void image:on_pushButton_2_clicked() timer-stop(); i-; if(i=0) i=j; pix.load(imagelisti); label-setPixmap(pix);void image:on_Open_clicked() int k = 0; QStringList list = QFileDialog:getOpenFileNames(this,选择图片,/,*.*); for(it=list.begin();itlist.end();it+) imagelistk=*it; qDebug()start(1000); pix.load(imagelisti); label-setPixmap(pix);void image:on_fangda_clicked() timer-stop(); double w=pix.width(); double h=pix.height(); pix = pix.scaled(w*1.05,h*1.05,Qt:KeepAspectRatio); label-setPixmap(pix);void image:on_suoxiao_clicked() timer-stop(); double w=pix.width(); double h=pix.height(); pix = pix.scaled(w*.95,h*.95,Qt:KeepAspectRatio); label-setPixmap(pix);void image:on_shun_clicked() timer-stop(); QMatrix matrix; matrix.rotate(90); pix = pix.transformed(matrix,Qt:FastTransformation); label-setPixmap(pix);void image:on_commandLinkButton_clicked() timer-stop(); QMatrix matrix; matrix.rotate(-90); pix = pix.transformed(matrix,Qt:FastTransformation); label-setPixmap(pix);五、效果显示六、分析和总结分析:这个设计的要求基本实现,但是仍然存在一些问题。第一个

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论