QT 1996 Sep 24 Qt 1 0 1996
- Slides: 78
QT的历史 ² 1996 Sep 24 Qt 1. 0 ² 1996 Oct KDE 组织成立 ² 1998 Apr 05 Trolltech 的程序员在 5 天之内将 Netscape 5. 0 从 Motif 移植到 Qt 上 ² 1998 Apr 08 KDE Free Qt 基金会成立 ² 1998 Jul 12 KDE 1. 0 发布 ² 1999 Jun 25 Qt 2. 0 发布 ² 2000 Mar 20 嵌入式 Qt 发布 ² 2000 Sep 06 Qt 2. 2 发布 ² 2000 Sep 04 Qt free edition 开始使用 GPL ² 2004 Aug 4. 0 ² 2008 Aug 4. 4发布, 集成Webkit和Phonon 5
9
QPainter绘制的图形: 16
Qt系统构造 库 描述 Qt. Core Qt. Gui 核心非GUI功能 核心GUI功能 Qt. Network Qt. Open. GL 网络模块 Open. GL 模块 SQL 模块 Qt. Sql Qt. Svg Qt. Xml Qt 3 Support QAx. Container QAx. Server Qt. Assistant Qt. Designer Qt. Ui. Tools Qt. Test SVG 透视图类 XML 模块 支持Qt 3的类 Active. Qt 客户端的扩充 Active. Qt 服务器段的扩充 Qt助手的语言类 Qt设计器的扩展类 生成动态GUI类 单元测试 具类 18
19
Signal和Slot的声明(一) 在Qt程序设计中,凡是包含signal和slot的类中都要加上 Q_OBJECT的定义,下面的例子给出了如何在一个类中定义 signal和slot: class Student : public QObject { Q_OBJECT public: Student() { my. Mark = 0; } int mark() const { return my. Mark; } public slots: void set. Mark(int new. Mark); signals: void mark. Changed(int new. Mark); private: int my. Mark; }; 28
Signal和Slot的声明(二) signal的发出一般在事件的处理函数中,利用emit 发出signal,在下面的例子中在在事件处理结束后发 出signal void Student: : set. Mark(int new. Mark) { if (new. Mark!= my. Mark) { my. Mark = new. Mark; emit mark. Changed(my. Mark); } } 29
Signal和Slot的连接(一) 在signal和slot声明以后,需要使用connect()函数 将它们连接起来。connect()函数属于QObject类的成 员函数,它能够连接signal和slot,也可以用来连接 signal和signal 函数原形如下: bool connect ( const QObject * sender, const char * signal, const char * member ) const 其中第一个和第三个参数分别指出signal和slot是 属于那个对象或组件 30
Signal和Slot的连接(二) 在使用connect()函数进行来接的时候,还需要用 到SIGNAL()和SLOT()这两个宏,使用方法如下: QLabel *label = new QLabel; QScroll. Bar *scroll = new QScroll. Bar; QObject: : connect( scroll, SIGNAL(value. Changed(int)), label, SLOT(set. Num(int)) ); 31
Signal和Slot的连接方式(二) ³ 同一个信号连接多个插槽 connect(slider, SIGNAL(value. Changed(int)), spin. Box, SLOT(set. Value(int))); connect(slider, SIGNAL(value. Changed(int)), this, SLOT(update. Status. Bar. Indicator(int))); ³ 多个信号连接到同一个插槽 connect(lcd, SIGNAL(overflow()), this, SLOT(handle. Math. Error())); connect(calculator, SIGNAL(division. By. Zero()), this, SLOT(handle. Math. Error())); 33
Signal和Slot的连接方式(三) ³ 一个信号连接到另一个信号 connect(line. Edit, SIGNAL(text. Changed(const QString &)), this, SIGNAL(update. Record(const QString &))); ³ 取消一个连接 disconnect(lcd, SIGNAL(overflow()), this, SLOT(handle. Math. Error())); ³ 取消一个连接不是很常用,因为Qt会在一个对象被 删除后自动取消这个对象所包含的所有的连接 34
HELLO QT(1) #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("Hello Qt!"); label->show(); return app. exec(); } 38
HELLO QT(2): 用HTML格式化 #include <Qt. Gui> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("<h 2><i>Hello</i> " "<font color=red>Qt!</font></h 2>"); label->show(); return app. exec(); } 39
创建链接 int main(int argc, char *argv[]) { QApplication app(argc, argv); QPush. Button *button = new QPush. Button("Quit"); QObject: : connect(button, SIGNAL(clicked()), &app, SLOT(quit())); button->show(); return app. exec(); } 40
基本布局(1) int main(int argc, char *argv[]) { QApplication app(argc, argv); QSpin. Box *spin. Box = new QSpin. Box; QSlider *slider = new QSlider(Qt: : Horizontal); QObject: : connect(spin. Box, SIGNAL(value. Changed(int)), slider, SLOT(set. Value(int))); QObject: : connect(slider, SIGNAL(value. Changed(int)), spin. Box, SLOT(set. Value(int))); 41
基本布局(2) QHBox. Layout *layout = new QHBox. Layout; layout->add. Widget(spin. Box); layout->add. Widget(slider); QHBox. Layout 水平布局管 理器 QWidget *window = new QWidget; window->set. Window. Title("Enter Your Age"); window->set. Layout(layout); window->show(); return app. exec(); } 42
QHBox. Layout水平布局管理器 #include <QApplication> #include <QLabel> #include <QPush. Button> #include <QHBox. Layout> #include <QWidget> int main(int argc, char *argv[]) { QApplication app (argc, argv); QHBox. Layout *hlayout=new QHBox. Layout(); QPush. Button *button=new QPush. Button("im ok"); QLabel *label = new QLabel("Hello Qt!"); QWidget *window = new QWidget; window->set. Window. Title("main"); hlayout->add. Widget(button); hlayout->add. Widget(label); window->set. Layout(hlayout); window->show(); return app. exec(); } 44
一个完整的Qt程序 1 #include <qapplication. h> 2 #include <qlabel. h> 3 int main(int argc, char **argv) 4 { 5 QApplication app (argc, argv); 6 QLabel *hello = new QLabel("Hello Qt/Embedded!", 0); 7 app. set. Main. Widget(hello); 8 hello->show(); 9 return app. exec(); 10 } 45
QObject类(一) class Mandelbrot: public QObject { Q_OBJECT //需要使用signal和slot public : Mandelbrot(QObect *parent=0, const char *name); …… public slots: void start(); signals: void done(); private slots: void calculate(); private: QTimer timer; …… }; 47
QObject类(二) //构造初始化一个Mandelbrot对象 Mandelbrot: : Mandelbrot(QObject *parent=0, const char *name) : QObject(parent, name) { connect(&timer, SIGNAL(timeout()), SLOT(calculate())); …… { 48
函数分组 系统设置 desktop. Settings. Aware()、set. Desktop. Settings. Aware()、cursor. Flash. Time()、set. Cursor. Flash. Time()、double. Click. Interval()、set. Double. Click. Interval()、 wheel. Scroll. Lines()、set. Wheel. Scroll. Lines()、palette()、set. Palette()、font()、set. Font()、font. Metrics()。 事件处理 exec()、process. Events()、enter_loop()、exit()、quit()。 send. Event()、post. Event()、send. Posted. Events()、remove. Posted. Events()、 has. Pending. Events()、notify()、mac. Event. Filter()、qws. Event. Filter()、x 11 Process. Event()、win. Event. Filter()。 图形用户 界面风格 style()、set. Style()、polish()。 颜色使用 color. Spec()、set. Color. Spec()、qws. Set. Custom. Colors()。 文本处理 set. Default. Codec()、install. Translator()、remove. Translator()、translate()。 窗口部件 main. Widget()、set. Main. Widget()、all. Widgets()、top. Level. Widgets()、desktop()、active. Popup. Widget()、active. Modal. Widget()、clipboard()、 focus. Widget()、win. Focus()、active. Window()、widget. At()。 高级光标处理 has. Global. Mouse. Tracking()、set. Global. Mouse. Tracking()、override. Cursor()、set. Override. Cursor()、restore. Override. Cursor()。 X窗口系统同步 flush. X()、sync. X()。 对话管理 is. Session. Restored()、session. Id()、commit. Data()、save. State()。 线程 lock()、unlock()、locked()、try. Lock()、wake. Up. Gui. Thread()。 杂项 close. All. Windows()、starting. Up()、closing. Down()、type()。 50
上下文 函数 窗口函数 show()、hide()、raise()、lower()、close()。 顶级窗口 caption()、set. Caption()、icon()、set. Icon()、icon. Text()、set. Icon. Text()、is. Active. Window()、set. Active. Window()、show. Minimized()、 show. Maximized()、show. Full. Screen()、show. Normal()。 窗口内容 update()、repaint()、erase()、scroll()、update. Mask()。 几何形状 pos()、size()、rect()、x()、y()、width()、height()、size. Policy()、set. Size. Policy()、size. Hint()、update. Geometry()、layout()、move()、resize()、 set. Geometry()、frame. Geometry()、geometry()、children. Rect()、adjust. Size()、map. From. Global()、map. From. Parent()、map. To. Global()、 map. To. Parent()、maximum. Size()、minimum. Size()、size. Increment()、set. Maximum. Size()、set. Minimum. Size()、set. Size. Increment()、 set. Base. Size()、set. Fixed. Size()。 模式 is. Visible()、is. Visible. To()、visible. Rect()、is. Minimized()、is. Desktop()、is. Enabled. To()、is. Modal()、is. Popup()、is. Top. Level()、 set. Enabled()、has. Mouse. Tracking()、set. Mouse. Tracking()、is. Updates. Enabled()、set. Updates. Enabled()。 观感 style()、set. Style()、cursor()、set. Cursor()、font()、set. Font()、palette()、set. Palette()、background. Mode()、set. Background. Mode()、 color. Group()、font. Metrics()、font. Info()。 键盘焦点函数 is. Focus. Enabled()、set. Focus. Policy()、focus. Policy()、has. Focus()、set. Focus()、clear. Focus()、set. Tab. Order()、set. Focus. Proxy()。 鼠标和键盘捕获 grab. Mouse()、release. Mouse()、grab. Keyboard()、release. Keyboard()、mouse. Grabber()、keyboard. Grabber()。 事件处理器 event()、mouse. Press. Event()、mouse. Release. Event()、mouse. Double. Click. Event()、mouse. Move. Event()、key. Press. Event()、key. Release. Event()、 focus. In. Event()、focus. Out. Event()、wheel. Event()、enter. Event()、leave. Event()、paint. Event()、move. Event()、resize. Event()、 close. Event()、drag. Enter. Event()、drag. Move. Event()、drag. Leave. Event()、drop. Event()、child. Event()、show. Event()、hide. Event()、 custom. Event()。 变化处理器 enabled. Change()、font. Change()、palette. Change()、style. Change()、window. Activation. Change()。 系统函数 parent. Widget()、top. Level. Widget()、reparent()、polish()、win. Id()、find()、metric()。 这是什么的帮助 custom. Whats. This()。 内部核心函数 focus. Next. Prev. Child()、wmapper()、clear. WFlags()、get. WFlags()、set. WFlags()、test. WFlags()。 54
第二部分: Qt Designer 57
59
Qt Designer的 作过程 ³ Qt Designer将 程文件组织成. ui的文件 ³ 由. ui文件生成. cpp 和. h文件 ². ui -----xml ² uic ³ 生成moc_filenaem. cpp ² moc 64
Qt Designer 功能框图 65
建立Qt/Embedded开发环境(二) ³ 解压缩并设置环境变量 ² 安装tmake cd ~/pxa 270 Qt tar –xzf tmake-1. 13. tar. gz export TMAKEDIR=$PWD/tmake-1. 13 ² 安装Qt 2. 3. 2 cd ~/pxa 270 Qt tar –xzf qt-x 11 -2. 3. 2. tar. gz export QT 2 DIR=$PWD/qt-2. 3. 2 ² 安装Qt/E 2. 3. 10 cd ~/pxa 270 Qt tar –xzf qt-embedded-2. 3. 10 -free. tar. gz export QTEDIR=$PWD/qt-2. 3. 10 69
建立Qt/Embedded开发环境(四) ³ 编译Qt 2. 3. 2 cd $QT 2 DIR export TMAKEPATH=$TMAKEDIR/lib/linux-g++ export QTDIR=$QT 2 DIR export PATH=$QTDIR/bin: $PATH export LD_LIBRARY_PATH=$QTDIR/lib: $LD_LIBRARY_PATH. /configure -no-xft make mkdir $QTEDIR/bin cp bin/uic $QTEDIR/bin/ 71
建立Qt/Embedded开发环境(五) ³ 编译qvfb export TMAKEPATH=$TMAKEDIR/lib/linux-g++ export QTDIR=$QT 2 DIR export PATH=$QTDIR/bin: $PATH export LD_LIBRARY_PATH=$QTDIR/lib: $LD_LIBRARY_PATH cd $QTEDIR/tools/qvfb tmake -o Makefile qvfb. pro make mv qvfb $QTEDIR/bin/ 72
建立Qt/Embedded开发环境(六) ³ 编译Qt/E 2. 3. 10 cd $QTEDIR export TMAKEPATH=$TMAKEDIR/lib/qws/linux-x 86 -g++ export QTDIR=$QTEDIR export PATH=$QTDIR/bin: $PATH export LD_LIBRARY_PATH=$QTDIR/lib: $LD_LIBRARY_PATH. /configure -no-xft -qvfb -depths 4, 8, 16, 32 make 73
建立Qt/Embedded开发环境(六) ³ 在qvfb上显示Qt程序 cd $QTEDIR/examples/launcher export QTDIR=$QTEDIR export PATH=$QTEDIR/bin: $PATH export LD_LIBRARY_PATH=$QTEDIR/lib: $QT 2 DIR/lib: $LD_LIBRARY_PATH qvfb -width 640 -height 480 & sleep 10. /launcher -qws 74
建立Qt/Embedded开发环境(六) ³ 编译在开发板上运行的Qt/E库 cd $QTEDIR export TMAKEPATH=$TMAKEDIR/lib/qws/linux-arm-g++ export QTDIR=$QTEDIR export PATH=$QTDIR/bin: $PATH export LD_LIBRARY_PATH=$QTDIR/lib: $LD_LIBRARY_PATH. /configure -xplatform linux-arm-g++ -no-xft -no-qvfb -depths 4, 8, 16, 32 make 75
一个完整的Qt程序开发过程(二) 4. 指定tmake路径 ± 本机编译 TMAKEPATH=/tmake的安装路径(如$TMAKEDIR)/lib/qws/linuxx 86 -g++ ± 交叉编译 TMAKEPATH=/tmake的安装路径(如$TMAKEDIR)/lib/qws/linuxarm-g++ 5. 通过tmake自动生成Makefile文件 tmake –o Makefilename. pro 6. make生成可执行文件 78
- Sep properties
- Scorstim
- Escuela segura sep
- La nueva escuela mexicana.sep.gob.mx
- Sep ecole
- Complejo pichanas
- Critères de mcdonald
- Ow sep
- Cnn 10 sep 7
- Conest sep hidalgo
- What is incose
- Calendario escolar 2001-2002 sep
- Complejo pichanas
- Modulo 23 fase 1
- Escuela segura sep
- Application form
- Sep computer
- Sep ipsf
- Importancia de la velocidad lectora
- Ece sep
- Syndrome de susac irm
- Calendario escolar 2009
- Sep i
- Szkolenie sep gliwice
- Real decreto 2242/1996
- Ottawa declaration 1996
- Os caçadores de tesouros 1996
- 23 march 1996
- Michael porter 1996
- 6/1996. (vii. 16.) müm rendelet
- Lunar 1996
- What is cimah regulation
- 1996 xxxi
- Normas iso dibujo tecnico
- Porterin geneeriset strategiat
- Frontera de productividad porter
- Toefl reading skills
- Teknologi informasi menurut haag dan keen
- Osha 1996
- Rocrd
- Morgan (1996)
- Morgan (1996)
- 1996 ap calculus ab free response
- Bachman and palmer 1996
- Modelo de besseyre des horts
- 1996 xxxi
- 1996 centennial olympics button
- Kronlid 1996
- Sebastian bredal
- Corium nuclear
- Selen soyder vikipedi
- Maxwell, 1996
- Telecommunications act of 1996
- S36 fla 1996
- Fasihi katika mifumo mbalimbali
- 1988-1996
- Hamletas 1996
- Feldman & gracon 1996
- Solar eclipse 1996
- Married persons equality act 1 of 1996
- Resolucion 2343 de 1996
- Ley 300 de 1996
- Iso-14011:1996 stands for
- Plan maestro del metro 1985
- Kometoidas
- 1996
- Rural development officer
- Fanta 4 namen
- Carta di lussemburgo 1996
- 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
- Pender 1996
- Decreto 1791 del 4 de octubre de 1996