sorry,刚才发现把程序抄错了.应该改成
#include "HelloWorld.h"
int main(int argc,char **argv)
{
QApplication a(argc,argv);
QWidget mainwindow;
mainwindow.setMinimumSize(200,100);
mainwindow.setMaximumSize(200,100);
QPushButton helloworld("Hello World!",&mainwindow);
helloworld.setGeometry(20,20,160,60);
// a.setMainWidget(&mainwindow);
mainwindow.show();
return a.exec();
}
有请大侠,如果我要加上去掉的那一行,就会出现错误,如下所示
[root@202 Qt]# make
g++ -c -pipe -g -D_REENTRANT -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0/include -I. -I. -o HelloWorld.o HelloWorld.cpp
In file included from HelloWorld.cpp:1:
HelloWorld.h:3:25: warning: no newline at end of file
HelloWorld.cpp: In function `int main(int, char**)':
HelloWorld.cpp:14: no matching function for call to `QApplication::
setMainWidget(QWidget*)'
make: *** [HelloWorld.o] Error 1
谢谢!
文字