By Dk Zhang
090807
一.Qt安装与编译
1.下载安装
在http://www.qtsoftware.com/downloads/sdk-windows-cpp下载Qt SDK for Windows它包括Qt libraries,Qt Creator IDE,Qt development tools。
现在的版本是:4.5.2
下载得到qt-sdk-win-opensource-2009.03.1exe,安装!
安装完成后,就可以用Qt Creator编写自己的Qt程序了。
二.在VC6.0中使用Qt
为了能够在VC6.0版本中使用Qt,需要做进一步的工作,接着上面的步骤写
2.编译
安装完成后,需要编译(Qt这点比较懒):
Windows 命令行进入安装目录C:/Qt/2009.03/qt
1)运行configuire.exe --help完成配置生成make文件
2)nmake
每一步都需要漫长的等待… 当然也有好心人把编译好的版本放到网上。
注意:
A.编译的前提是安装VC6.0,并且保证nmake.exe在正确的路径中,测试方法:
命令行输入nmake /?
输出
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp1988-1998. All rights reserved.
Usage: NMAKE @commandfile
NMAKE [options] [/f makefile] [/x stderrfile] [macrodefs] [targets]
Options:
如果不在,切换到路径C:/Program Files/Microsoft Visual Studio/VC98/Bin(VC路径),运行vcvars32.bat ,设置vc6.0编译文件的路径。
B.编译的目的是生成VC编译和运行需要的lib和dll文件
3. 设置环境变量
PATH = C:/Qt/2009.03/qt/bin
QMAKESPEC = win32-msvc
然后重启一下命令行窗口,检查路径设置的是否正确:
C:/>qmake -v
QMake version 2.01a
Using Qt version 4.5.2 in C:/Qt/2009.03/qt/lib
C:/> echo %QMAKESPEC%
win32-msvc
至此,QT与VC6.0就OK了。
4.实用
下面用一个小程序测试一下,创建文件名为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();
}
然后命令行:
> qmake -project -o hello.pro 生成pro文件
> qmake 生成makefile
> nmake 生成 可执行文件
或者利用
> qmake -project -o hello.pro 生成pro文件
> qmake –tp vc –o hello.dsp生成VC工程文件
就可以用VC6.0打开工程进行接下来的操作
三. 错误处理
Qt编程中经常会出现:
finddialog.obj : error LNK2001: unresolved external symbol
"public:~virtual int __thiscall MyClass::qt_metacall(enum QMetaObject::Call,int,void * *)"
《Implementation of ImageViewerQt with Qt4》中解释:
“If this ever happens to you, run qmake again to update the makefile, then rebuild the application.”
四. 推荐网站
http://www.qtcn.org/bbs/index.php
http://sites.google.com/site/chaishushan/qt
本文详细介绍如何在VC6.0环境中安装和配置Qt开发工具,包括Qt SDK的下载、编译过程及环境变量的设置,并提供了一个简单的Qt程序示例。
3687

被折叠的 条评论
为什么被折叠?



