• 5115阅读
  • 2回复

hello world也出错.... [复制链接]

上一主题 下一主题
离线style
 
只看楼主 倒序阅读 楼主  发表于: 2006-05-12
#include <qapplication.h>
#include <qpushbutton.h>


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: *** [qt.o] 错误 1
root@style:/zb/souqt#      




郁闷,我安装的QT4.01
[ 此贴被XChinux在2006-05-12 08:20重新编辑 ]
离线chwoozy

只看该作者 1楼 发表于: 2006-05-12
你用Qt3的Helloworld的例子在Qt4下编译当然会出错了。Qt4的Helloworld源代码里除了没有下面这一句外其它都和Qt3Helloworld的源代码相同:
a.setMainWidget( &hello );
离线style
只看该作者 2楼 发表于: 2006-05-12
谢谢.知道了.```
快速回复
限100 字节
 
上一个 下一个