久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

QT helloworld 程序

作者:huqin   來源:本站原創   點擊數:  更新時間:2014年03月12日   【字體:
1、 搭建嵌入式交叉環境
 

a.      交叉編譯工具鏈接

b.      主機交叉編譯環境配置

c.      Bootloderlinux內核,文件系統構建

2、 簡單的helloworld 程序

增加執行權: chmod u+x  ./ qt-sdk-linux-x86-opensource-2010.04.bin

a. File->New菜單來新建工程。

b.選擇Qt4 Gui Application

c.輸入工程名helloworld

d.軟件自動添加基本的頭文件

e.base class選為QDialog對話框類

f.完成工程的建立

g.工程中的所有文件都出現在列表

h.雙擊文件列表的dialog.ui文件

i.找到Label標簽器件,拖到設計窗口上

j.雙擊它,并將其內容改為hello world

 

3、 Helloworld程序的編譯

在主機的\root\helloworld目錄下:

生成Makefile文件

qmake –project

編譯程序:make 生成helloworld 程序

#cp ./helloworld /nfs/app/

在目標機上:#cd ./app 運行程序:#./helloworld -qws

 

3.目標機的運行環境

a. bootloder /tftpboot/目錄下

b. linux內核(2.6

c. 包含qt的文件系統:有兩種方式下載,直接下載目標機(rootfs.img)或者用nfs方式下載

 

4、 編譯代碼:先要設置它在PC里面還是在目標機中(Tools--->Options)

PC QT4.5.3opensource,如果選了它,可以在PC機運行。

目標機:QT4.5.3,只能Build All

5、 復雜的hello程序

新建GUI hello工程,選擇wedget

放一個lable 三個pushbutton

選擇pushbutton –>goto slot –>設置Labeltext的函數:ui->lblHello->setText("Good, World");

6、 信號和槽

發一個信號,會有槽(SLOT)來響應它

cmdClose這個buttonclicked()     on_cmdClose_clicked()

 

也可以使用connect這個函數來做到

connect(ui->cmdClose, SIGNAL(clicked()),this, SLOT(on_cmdClose_clicked()))

7、 標準對話框

標準的文件對話框(QFileDialog)、標準的顏色對話框(QColorDialog)、標準的字體對話框(QFontDialog

建立standardDialog GUI工程  Dialog窗口

三個pushbutton 一個lineEdit 一個Frame 一個lineEdit

 

頭文件:文件對話框(QFileDialogQSring、字體對話框(QFontQFontDialog

顏色對話框(QColorQColorDialogQPalete

#include<QFileDialog>

#include<QString>

#include<QFont>

#include<QFontDialog>

#include<QColor>

#include<QPalette>

#include<QColorDialog>

對應的.cpp代碼

文件:注意QFileDialog::getOpenFileName()setText(s.toAscii())

QStrings=QFileDialog::getOpenFileName(this, "Open File Dialog","/", "C++ files(*.cpp);;Headfiles(*.h)");

ui->txtFile->setText(s.toAscii());

 

字體:注意QFontDialog:getFont(&ok)setFont(font)

 bool ok;

QFontfont = QFontDialog::getFont(&ok);

if(ok)

{

         ui->txtFont->setFont(font);

}

顏色:注意QColorDialog::getColor(Qt::blue)setAutoFillBackground(true)setPalette(QPalette(color))

QColorcolor = QColorDialog::getColor(Qt::blue);

if(color.isValid())

{

ui->frmColor->setAutoFillBackground(true);  

ui->frmColor->setPalette(QPalette(color));

}

 

8、標準輸入框

多文本

QInputDialog::getText(this,"inputuser name!","Please input user name:", QLineEdit::Normal,nameLa bel->text(),&ok);

txtName->setText(s.toAscii());

有限文本

QInputDialog::getItem(this,"Input***!", "Please select the ***:",list, 0,false,&ok);

ui->txtSex->setText(s.toAscii());

整數輸入

QInputDialog::getInteger(this,"Input the Age!","Please input theage:",ageLabel->text().toInt(),0,150,1,&ok);

ui->txtAge->setText(QString(tr("%1")).arg(age));

實數輸入

QInputDialog::getDouble(this,"Input the height!","Please input theheight:",175,0,230,1,&ok);

ui->txtHeight->setText(QString(tr("%1")).arg(height));

 

8、   標準消息框

消息:提問(question)、信息(information)、警告(warning)、致命提示(critical

頭文件:QMessageBox

#include<QMessageBox>

.cpp文件

Int  ret;

Ret=QMessageBox::question()

Ret=QMessageBox::information()

Ret=QMessgeBox::warning();

Ret=QmerssageBox::critical();

關閉窗口

相關文章

主站蜘蛛池模板: 国内精品99 | 日日碰狠狠躁久久躁婷婷 | 日韩欧美电影在线 | 欧美国产日本一区 | 亚洲精品1区 | 精品一区二区三区在线视频 | 99精品国产一区二区青青牛奶 | 日韩午夜一区二区三区 | 中文字幕福利视频 | www.v888av.com| 一级欧美视频 | 青青久久久 | 91免费版在线观看 | 国产福利视频 | 爱爱免费视频网站 | 久久人人爽人人爽人人片av免费 | 国产精品中文字幕在线播放 | 精品av天堂毛片久久久借种 | 男女污网站 | 色五月激情五月 | 国产精品96久久久久久 | 亚洲一区二区在线播放 | 成人水多啪啪片 | 欧美最猛性xxxxx亚洲精品 | 一区二区成人 | 成人精品 | 中文字幕第一页在线 | 亚洲成人黄色 | 国产精品高潮呻吟久久av野狼 | 色视频网站 | 一区二区三区免费在线观看 | www.日韩系列 | 成人av激情 | 成人免费小视频 | 国产性网 | 国产精品99久久免费观看 | 国产精品精品视频一区二区三区 | 亚洲精品乱码久久久久久按摩观 | 久久国| 国产日韩一区 | 99久久精品一区二区成人 |