DEV-C++ 和 QT4 合拍 - 小橙子的第一播 - CSDNBlog

来源:互联网 发布:淘宝怎么设置返现 编辑:程序博客网 时间:2024/06/12 01:49
DEV-C++ 5 一个很不错的免费 C/C++ IDE。QT4 也是很不错的 UI 库。不知道是不是他们前世有什么仇,并不是那么合拍。Dev-C++的Makefile.win 不适合 QT4 的编译情况。而使用 qmake 生成的 makefile.release 才非常合适。

一、下载和安装 这步骤就不多说了,只留下下载的地址就好了。
DEV-C++ 下载地址:http://sourceforge.net/projects/dev-cpp/
QT4.2.3 下载地址:http://www.trolltech.com/products/qt/downloads

二、配置 1、配置编译器选项 在 devcpp.ini 增加以下的内容
[CompilerSets_2]
gcc.exe=gcc.exe
g++.exe=g++.exe
gdb.exe=gdb.exe
make.exe=mingw32-make.exe
windres.exe=windres.exe
dllwrap.exe=dllwrap.exe
gprof.exe=gprof.exe
Options=1000001000000000000000
cmdline=-O2 -O2 -frtti -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
LinkLine=-mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows
CompAdd=1
LinkAdd=1
Bins=C:/Cplus/Dev-Cpp/Bin;C:/Cplus/Qt423/bin
C=C:/Cplus/Dev-Cpp/include
Cpp=C:/Cplus/Dev-Cpp/lib/gcc/mingw32/3.4.2/include;C:/Cplus/Dev-Cpp/include/c++/3.4.2/backward;C:/Cplus/Dev-Cpp/include/c++/3.4.2/mingw32;C:/Cplus/Dev-Cpp/include/c++/3.4.2;C:/Cplus/Dev-Cpp/include;C:/Cplus/Qt423/include/QtXml;C:/Cplus/Qt423/include;C:/Cplus/Qt423/include/Qt;C:/Cplus/Qt423/include/QtCore;C:/Cplus/Qt423/include/QtGui;C:/Cplus/Qt423/mkspecs/win32-g++;C:/Cplus/Qt423/include/QtSql
Lib=C:/Cplus/Dev-Cpp/lib;C:/Cplus/Qt423/lib

[CompilerSets]
2=GCC MingW32 - QT4.2.3

[ExternalPrograms]
Dummy=0

[ExternalPrograms.Programs]
.ui=C:/Cplus/Qt423/bin/designer.exe

2、创建 template 首先,在%DEVCPP_ROOT%/template 创建 QTApp.template ,文件的内容如下:
[Template]
ver=1
Name=QT Application
Icon=Qt.ico
Description=This is a QT Application project.
Catagory=QT

[Unit0]
CppName=main.cpp
Cpp=Qt4.txt

[Project]
UnitCount=1
Type=1
IsCpp=1
Compiler=
CppCompiler=-DWIN32_@@__@@__@@_
Linker=-lmingw32 -lqtmain -lQtCore4 -lQtGui4_@@__@@__@@_
CompilerSettings=1000001000000000000000
CompilerSet=2
IncludeVersionInfo=0
SupportXPThemes=0
Includes=C:/Cplus/Qt423/mkspecs/win32-g++;C:/Cplus/Qt423/include
Libs=C:/Cplus/Qt423/lib
ResourceIncludes=
Name=QT Application project
ProjectIcon=QT Application.project.ico
MakeIncludes=QT_UIMake.mak
UseCustomMakefile=1
CustomMakefile=Makefile.Release
ExeOutput=release
ObjectOutput=release


相同的目录,再创建 Qt4.txt ,文件的内容如:
#include
#include

int main(int argc, char *argv[])
...{
QApplication app(argc, argv);

QPushButton hello("Hello world!");
hello.resize(100, 30);

hello.show();
return app.exec();
}

需要说明的是,模板的文件(qt4.txt)可以自己根据 .template 来扩展。

三、创建工程、测试 创建工程,选择 QT 页下面的 QT Application 。 设定工程的属性:
1、工程类型,根据实际情况修改
2、Build选项中,输出改为 release
3、MakeFile 中,修改为 makefile.release
4、使用 qmake 生成 makefile.release , qmake -project qmake 如果工程非常小、没有自定义的对象,不用修改makefile和输出目录。

至此,完成了安装、配置。可以放心使用了。

本文转自
http://blog.csdn.net/cangwu_lee/archive/2007/05/21/1619270.aspx