1.获取Qt Creator和Qt库
qt-creator-win-opensource-2.2.1.exe (52MB)
http://get.qt.nokia.com/qtcreator/qt-creator-win-opensource-2.2.1.exe
qt-win-opensource-4.7.3-mingw.exe
http://get.qt.nokia.com/qt/source/qt-win-opensource-4.7.3-mingw.exe
2.安装Qt Creator
参考安装路径:D:\Qt\qtcreator-2.2.1
3.安装Qt库
参考安装路径:D:\Qt\4.7.3
安装过程会出现提示,要求定位mingw的位置,此时可浏览到Qt Creator安装目录下的mingw目录,即:D:\Qt\qtcreator-2.2.1\mingw
4.Qt Creator配置
启动Qt Creator,选择菜单 [工具] --> [选项],然后点击左侧的 [Qt4] 标签页,接着点击右上角的 [添加],接下来点击下方的 [浏览],
浏览到qmake所在的路径,此处即: D:\qt\4.7.3\bin\qmake.exe 最后应用该设置,设置完成后最好重新启动一下Qt Creator
5.创建并运行HelloWorld
文件->新建文件或工程->Qt Quick项目->Qt Quick UI
6.直接运行可执行文件(设置PATH环境变量,把Qt和MinGW加进去)
若希望直接双击执行工程 [构建目录] 下的 [debug] 或 [release] 目录下的可执行文件,须添加如下环境变量:
计算机->属性->高级系统设置->环境变量->PATH->编辑
添加 D:\Qt\qtcreator-2.2.1\mingw\bin;D:\Qt\4.7.3\bin
---------------------------------------------------------------------------------
Qt的使用
---------------------------------------------------------------------------------
QT下面,第一个程序的运行过程:
1.把如下的程序拷贝到文件“hello.cpp”中:
#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();
}
2.将文件“hello.cpp”保存在目录“D:\Qt\test\1\hello”下
3.选择“Qt 4.7.3 Command Prompt”,进入命令行界面,进入刚才保存“hello.cpp”的目录(主要用DOC命令:cd D:\Qt\test\1\hello )
4.在命令提示符后面,分别输入:
qmake -project
(to create a platform-independent project file (hello.pro))
qmake hello.pro
(to create a platform-specific makefile from the project file)
make
(to build the program)
5.经过以上三个步骤以后,在“hello.cpp”所在的目录下,得到以下一系列文件
6.在这个目录下面的“debug”文件夹下面,得到一个windows下面的可执行程序“hello.exe”:
------------------------------------ THE END ---------------------------------------------