QT开发--hello

来源:互联网 发布:淘宝iPhone7 编辑:程序博客网 时间:2024/05/05 06:47

创建QT第一个小程序:

使用标签创建一个窗口,并显示  "hello QT!"

1.创建cpp文件:hello.cpp

#include <QApplication>#include <QLabel>                  //标签int main(int argc,char *argv[]){        QApplication app(argc,argv);            //创建QApplication对象app管理应用程序        QLabel *label = new QLabel("Hello QT!");//创建一个标签对象//QLabel *label = new QLabel("<h2><i>Hello</i> ""<font color=red>QT!</font></h2>");        label->show();                          //显示标签        return app.exec();                      //进入程序主循环}

2.使用Windows下的命令行,进入hello.cpp目录下;

3.使用命令"qmake -project",来创建工程;产生  hello.pro 文件


4.使用命令"qmake hello.pro",来产生makefile文件;



5.使用命令"make",对工程进行编译;

6.进入 debug 目录中,运行hello.exe。

             

至此,hello 工程从编写、创建、编译和运行完成!




F:\QT_Program\test01\hello>qmake -project

F:\QT_Program\test01\hello>qmake  hello.pro

F:\QT_Program\test01\hello>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `F:/QT_Program/test01/hello'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -
DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\Qt\4.7
.3\include\QtCore" -I"d:\Qt\4.7.3\include\QtGui" -I"d:\Qt\4.7.3\include" -I"." -
I"d:\Qt\4.7.3\include\ActiveQt" -I"debug" -I"d:\Qt\4.7.3\mkspecs\win32-g++" -o d
ebug\hello.o hello.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\hello.exe debug/hello.o  -L"d:\
Qt\4.7.3\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `F:/QT_Program/test01/hello'




F:\QT_Program\test01\hello>debug\hello.exe


F:\QT_Program\test01\hello>




0 0
原创粉丝点击