a. 交叉編譯工具鏈接
b. 主機(jī)交叉編譯環(huán)境配置
c. Bootloder,linux內(nèi)核,文件系統(tǒng)構(gòu)建
2、 簡(jiǎn)單的helloworld 程序
增加執(zhí)行權(quán): chmod u+x ./ qt-sdk-linux-x86-opensource-2010.04.bin
a. 用File->New菜單來(lái)新建工程。
b.選擇Qt4 Gui Application
c.輸入工程名helloworld
d.軟件自動(dòng)添加基本的頭文件
e.base class選為QDialog對(duì)話框類(lèi)
f.完成工程的建立
g.工程中的所有文件都出現(xiàn)在列表
h.雙擊文件列表的dialog.ui文件
i.找到Label標(biāo)簽器件,拖到設(shè)計(jì)窗口上
j.雙擊它,并將其內(nèi)容改為hello world
3、 Helloworld程序的編譯
在主機(jī)的\root\helloworld目錄下:
生成Makefile文件
qmake –project
編譯程序:make 生成helloworld 程序
#cp ./helloworld /nfs/app/
在目標(biāo)機(jī)上:#cd ./app 運(yùn)行程序:#./helloworld -qws
3.目標(biāo)機(jī)的運(yùn)行環(huán)境
a. bootloder 在/tftpboot/目錄下
b. linux內(nèi)核(2.6)
c. 包含qt的文件系統(tǒng):有兩種方式下載,直接下載目標(biāo)機(jī)(rootfs.img)或者用nfs方式下載
4、 編譯代碼:先要設(shè)置它在PC里面還是在目標(biāo)機(jī)中(Tools--->Options)
PC: QT4.5.3opensource,如果選了它,可以在PC機(jī)運(yùn)行。
目標(biāo)機(jī):QT4.5.3,只能Build All
5、 復(fù)雜的hello程序
新建GUI 的hello工程,選擇wedget
放一個(gè)lable 三個(gè)pushbutton
選擇pushbutton –>goto slot –>設(shè)置Label的text的函數(shù):ui->lblHello->setText("Good, World");
6、 信號(hào)和槽
發(fā)一個(gè)信號(hào),會(huì)有槽(SLOT)來(lái)響應(yīng)它
cmdClose這個(gè)button發(fā)clicked() on_cmdClose_clicked()
也可以使用connect這個(gè)函數(shù)來(lái)做到
connect(ui->cmdClose, SIGNAL(clicked()),this, SLOT(on_cmdClose_clicked()))
7、 標(biāo)準(zhǔn)對(duì)話框
標(biāo)準(zhǔn)的文件對(duì)話框(QFileDialog)、標(biāo)準(zhǔn)的顏色對(duì)話框(QColorDialog)、標(biāo)準(zhǔn)的字體對(duì)話框(QFontDialog)
建立standardDialog GUI工程 Dialog窗口
三個(gè)pushbutton 一個(gè)lineEdit 一個(gè)Frame 一個(gè)lineEdit
頭文件:文件對(duì)話框(QFileDialog、QSring)、字體對(duì)話框(QFont、QFontDialog)
顏色對(duì)話框(QColor、QColorDialog、QPalete)
#include<QFileDialog>
#include<QString>
#include<QFont>
#include<QFontDialog>
#include<QColor>
#include<QPalette>
#include<QColorDialog>
對(duì)應(yīng)的.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、標(biāo)準(zhǔn)輸入框
多文本
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());
整數(shù)輸入
QInputDialog::getInteger(this,"Input the Age!","Please input theage:",ageLabel->text().toInt(),0,150,1,&ok);
ui->txtAge->setText(QString(tr("%1")).arg(age));
實(shí)數(shù)輸入
QInputDialog::getDouble(this,"Input the height!","Please input theheight:",175,0,230,1,&ok);
ui->txtHeight->setText(QString(tr("%1")).arg(height));
8、 標(biāo)準(zhǔn)消息框
消息:提問(wèn)(question)、信息(information)、警告(warning)、致命提示(critical)
頭文件:QMessageBox
#include<QMessageBox>
.cpp文件
Int ret;
Ret=QMessageBox::question()
Ret=QMessageBox::information()
Ret=QMessgeBox::warning();
Ret=QmerssageBox::critical();