




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、.基于QT的電子相冊設(shè)計(jì)一、設(shè)計(jì)內(nèi)容及要求:1)能從存儲卡中讀取圖像文件,并在LCD屏上顯示圖像文件,支持多種主流格式;2)顯示時(shí)間、日期;3)通過按鈕或觸摸屏進(jìn)行操作。二、設(shè)計(jì)目的1)了解Linux嵌入式2)了解QT的設(shè)計(jì)過程3)了解PC機(jī)和開發(fā)板之間的通信三、設(shè)計(jì)工具PC機(jī)、開發(fā)板四、設(shè)計(jì)過程1、功能模塊結(jié)構(gòu)架構(gòu)圖功能模塊圖片瀏覽模塊圖片播放模塊系統(tǒng)設(shè)計(jì)模塊2、具體功能模塊架構(gòu)圖圖片瀏覽模塊圖像正旋圖像反旋圖像放大圖像縮小上一張圖片下一張圖片圖像播放和系統(tǒng)設(shè)計(jì)模塊選擇加載圖片圖片播放4、基于QT的圖像界面設(shè)計(jì)顯示5、用戶界面層代碼設(shè)計(jì)#include "mainwindow.h&
2、quot;#include "ui_mainwindow.h"MainWindow: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_y
3、ratio = 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、用戶圖形界面的按鈕功能實(shí)現(xiàn)代碼vo
4、id 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_in
5、dex-; if(image_index<0) image_index = image_sum-1; return;void MainWindow:image_show(void) /check error if(0=image_sum) return; if(image_index>=image_sum |image_index<0) image_index = 0; /load iamge pix.load(image_listimage_index); /rotate image if(disp_angle!=0) QMatrix matrix; matrix.rota
6、te(disp_angle); pix = pix.transformed(matrix,Qt:FastTransformation); /scale image long image_width = pix.width(); long image_height = pix.height(); if(image_width*disp_height>image_height*disp_width) image_height *= (disp_width/(double)image_width); image_width *= (disp_width/(double)image_width)
7、; 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_pushBu
8、tton_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();it<list.end();it+) image_listk=*it; k+; if(k=0) return;
9、 /save number of images image_sum = k; image_index = 0; disp_xratio = 1.0; disp_yratio = 1.0; disp_angle = 0; /start timer timer->start(timer_second); this->image_show(); return;void MainWindow:on_pushButton_stop_clicked() timer->stop(); return;void MainWindow:on_pushButton_play_clicked() t
10、imer->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; /sto
11、p 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_xratio>0.05)disp_xratio
12、 -= 0.05; if(disp_yratio>0.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、功能模塊實(shí)現(xiàn)代碼:#include "image.h"#inc
13、lude "ui_image.h"int 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(thi
14、s); /給窗體設(shè)置背景圖片 QImage image1; image1.load(":/6.PNG"); /括號內(nèi)為圖片的相對目錄 QImage image2 = image1.scaled(320,240); QPalette palette;/定義窗口 palette.setBrush(this->backgroundRole(),QBrush(image2); this->setPalette(palette);/在定義的窗口顯示 timer = new QTimer; label = new QLabel;/不報(bào)錯(cuò)但運(yùn)行不出,頭文件聲明必須初始化 /m
15、atrix= 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
16、(pix); i+; if(i>j) i=0; image:image() delete ui;void image:on_pushButton_clicked() timer->start(1000); pix.load(imagelisti); label->setPixmap(pix); i+; if(i>j) i=0; void image:on_Pause_clicked() timer->stop();void image:on_UP_clicked() timer->stop(); i+; if (i=j) i=0; pix.load(imag
17、elisti); 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(i
18、t=list.begin();it<list.end();it+) imagelistk=*it; qDebug()<<imagelistk; k+; j=k-1; timer->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
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 應(yīng)對不確定性公司的戰(zhàn)略與風(fēng)險(xiǎn)管理試題及答案
- 網(wǎng)絡(luò)配置與策略執(zhí)行試題及答案
- 如何利用數(shù)字辦公平臺提升企業(yè)創(chuàng)新能力
- 2025年網(wǎng)絡(luò)管理員考試方法總結(jié)試題
- 校招:云計(jì)算筆試試題及答案
- 校招:網(wǎng)絡(luò)工程面試題及答案
- 神經(jīng)康復(fù)臨床護(hù)理
- 軟件設(shè)計(jì)師學(xué)術(shù)研究試題及答案
- 企業(yè)數(shù)字化辦公平臺的構(gòu)建策略
- 校招:軟件研發(fā)崗筆試試題及答案
- 第七章 循證醫(yī)學(xué)課件
- 風(fēng)電專業(yè)考試題庫帶答案
- 艾滋病職業(yè)防護(hù)培訓(xùn)
- 教學(xué)反思不足之處和改進(jìn)措施簡短
- 舒適化醫(yī)療麻醉
- 露營地合伙人合同協(xié)議書范本
- 2024年315消費(fèi)者權(quán)益保護(hù)知識競賽題庫及答案(完整版)
- 2024秋期國家開放大學(xué)《可編程控制器應(yīng)用實(shí)訓(xùn)》一平臺在線形考(形成任務(wù)1)試題及答案
- 2023年高考真題-地理(河北卷) 含答案
- DB50-T 1649-2024 餐飲業(yè)菜品信息描述規(guī)范
- GB/T 17775-2024旅游景區(qū)質(zhì)量等級劃分
評論
0/150
提交評論