标题:hello world也出错....
作者:style
日期:2006-05-12 00:58
内容:
#include
#include
int main( int argc, char *argv[] )
{
QApplication a(argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
a.setMainWidget( &hello );
hello.show();
return a.exec();
}
root@style:/zb/souqt# qmake -project
root@style:/zb/souqt# qmake
root@style:/zb/souqt# make
g++ -c -pipe -g -Wall -W -D_REENTRANT-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.2/include/QtCore -I/usr/local/Trolltech/Qt-4.1.2/include/QtGui -I/usr/local/Trolltech/Qt-4.1.2/include -I. -I. -I. -o qt.o qt.cpp
qt.cpp: In function `int main(int, char**)':
qt.cpp:27: error: `setMainWidget' undeclared (first use this function)
qt.cpp:27: error: (Each undeclared identifier is reported only once for each
function it appears in.)
make: *** 错误 1
root@style:/zb/souqt#
郁闷,我安装的QT4.01
#1 [chwoozy 05-12 13:18]
你用Qt3的Helloworld的例子在Qt4下编译当然会出错了。Qt4的Helloworld源代码里除了没有下面这一句外其它都和Qt3Helloworld的源代码相同:
a.setMainWidget( &hello );
#2 [style 05-12 13:40]
谢谢.知道了.```