我使用的是QT5.1,什么的都包装好了,还自带了QTCreator,直接下载下来运行
http://qt-project.org/downloads
Qt 5.1.0 for Windows 32-bit (MinGW 4.8, OpenGL, 666 MB)
Qt5.1.0\Tools\mingw48_32
QT5.1中有自带MinGW 4.8,配置好mingw环境变量,就可以了
HelloWorld
#include "mainwindow.h"
#include <qapplication.h>
#include <qpushbutton.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton hello("Hello World", 0);
hello.resize(100,60);
a.setActiveWindow(&hello);
hello.show();
return a.exec();
}
环境变量
C_HOME F:\Program\Qt\Qt5.1.0\Tools\mingw48_32
PATH %C_HOME%\bin
LIBRARY_PATH %C_HOME%\lib
C_INCLUDEDE_PATH %C_HOME%\include
CPLUS_INCLUDE_PATH %C_HOME%\include\c++\3.4.5;%C_HOME%\include\c++\3.4.5\backward;%C_HOME%\include
helloworld.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = helloworld
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
在5.1中,手动构建QT的dome时,需要在 *.pro文件中加入下位两句:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets