Qt with VC 6.0

By Dk Zhang

090807

一.Qt安装与编译

1.下载安装

http://www.qtsoftware.com/downloads/sdk-windows-cpp下载Qt SDK for Windows它包括Qt librariesQt Creator IDEQt 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文件

2nmake

每一步都需要漫长的等待当然也有好心人把编译好的版本放到网上。

 

注意:

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编译和运行需要的libdll文件

 

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

 

至此,QTVC6.0OK了。

 

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.insideqt.com

http://www.qtcn.org/bbs/index.php

http://wiki.qtcentre.org/

http://sites.google.com/site/chaishushan/qt

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值