你的程序我是这样做的,你试一下
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
保存为D:\Study\QT\exg\QT4-exg\Form\main.cpp
进入命令行编译,以下是编译过程
-------------------------------------------
D:\Study\QT\exg\QT4-exg\Form>qmake -project
D:\Study\QT\exg\QT4-exg\Form>qmake
D:\Study\QT\exg\QT4-exg\Form>make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/Study/QT/exg/QT4-exg/Form'
g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
-DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEED
_QMAIN -I"c:\Qt\4.3.1\include\QtCore" -I"c:\Qt\4.3.1\include\QtCore" -I"c:\Qt\4
3.1\include\QtGui" -I"c:\Qt\4.3.1\include\QtGui" -I"c:\Qt\4.3.1\include" -I"."
I"c:\Qt\4.3.1\include\ActiveQt" -I"release" -I"." -I"c:\Qt\4.3.1\mkspecs\win32-
++" -o release\main.o main.cpp
main.cpp:10:2: warning: no newline at end of file
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-re
oc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o "release\Form.exe" release\ma
n.o -L"c:\Qt\4.3.1\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
mingw32-make[1]: Leaving directory `D:/Study/QT/exg/QT4-exg/Form'