回复: 【提问】才学QT。这么简单的程序在错了?在kdevelop下编译出错~
#6 [XChinux 08-25 10:26]
对,写Qt程序用qmake管理工程比较的方便些。
#7 [magicoy 08-25 16:36]
#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();
}
------------------------------------------------------
cd '/usr/cqt/qapp' && QTDIR="/usr/lib/qt-3.3" gmake -k
正在编译 qapp.cpp (g++)
qapp.cpp:7: error: expected primary-expression before ']' token
*** 退出状态:2 ***
#8 [XChinux 08-25 16:39]
下面是引用magicoy于2005-08-25 16:36发表的:
#include
#include
int main( int argc, char *argv[] )
.......
应该是
QApplication a(argc, argv);
#9 [magicoy 08-25 16:40]
#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();
}
--------------------------------------------------------------
cd '/usr/cqt/qapp' && QTDIR="/usr/lib/qt-3.3" gmake -k
正在联接 ../bin/qapp (g++)
/usr/lib/qt-3.3/include/qglist.h:151: multiple definition of `main'
qapp.o(.text+0x0):/usr/lib/qt-3.3/include/qglist.h:151: first defined here
/usr/cqt/qapp/src/moc_qapp.cpp:106: undefined reference to `Qapp::aboutQt()'
moc_qapp.o(.text+0x261):/usr/cqt/qapp/src/moc_qapp.cpp:99: undefined reference to `Qapp::newDoc()'
moc_qapp.o(.text+0x270):/usr/cqt/qapp/src/moc_qapp.cpp:100: undefined reference to `Qapp::choose()'
/usr/lib/qt-3.3/include/private/qucom_p.h:449: undefined reference to `Qapp::load(QString const&)'
/usr/cqt/qapp/src/moc_qapp.cpp:102: undefined reference to `Qapp::save()'
moc_qapp.o(.text+0x2a6):/usr/cqt/qapp/src/moc_qapp.cpp:103: undefined reference to `Qapp::saveAs()'
moc_qapp.o(.text+0x2b6):/usr/cqt/qapp/src/moc_qapp.cpp:104: undefined reference to `Qapp::print()'
moc_qapp.o(.text+0x2c6):/usr/cqt/qapp/src/moc_qapp.cpp:105: undefined reference to `Qapp::about()'
*** 退出状态:2 ***
#10 [XChinux 08-25 16:43]
不会吧,上面的程序根本用不着moc。肯定是你工程的问题。