<DIV mb10?>本人是新手,刚开始学QT,按照例题用“QT4控制台应用”模板写了两个程序,代码如下:
程序1 :
#include <QtCore/QCoreApplication><DIV mb10?>#include <QApplication><DIV mb10?>#include <QPushButton><DIV mb10?>int main( int argc, char* argv[] )<DIV mb10?>{ <DIV mb10?> QApplication a(argc, argv ); <DIV mb10?> QPushButton* hello = new QPushButton( "Hello world!", 0 ); <DIV mb10?> hello -> resize( 100, 30 ); <DIV mb10?> hello -> show(); <DIV mb10?> return a.exec();<DIV mb10?>}<DIV mb10?>程序2:
#include <QtCore/QCoreApplication><DIV mb10?>#include <QApplication><DIV mb10?>#include <QPushButton><DIV mb10?>#include <QFont><DIV mb10?>int main(int argc, char *argv[])<DIV mb10?>{ <DIV mb10?> QApplication a(argc, argv); <DIV mb10?> QPushButton quit=new QPushButton( "Quit", 0 ); <DIV mb10?> quit->resize( 75, 30 ); <DIV mb10?> quit->setFont( QFont( "Times", 18, QFont::Bold ) ); <DIV mb10?> QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) ); <DIV mb10?> a.setMainWidget( &quit ); <DIV mb10?> quit.show(); <DIV mb10?> return a.exec();}<DIV mb10?>程序1运行没有问题,但程序2编译时提示:
(1)QApplication:NO such file or directory.
(2) QPushButton:NO such file or directory.
......
我感到很疑惑,QApplication和QPushButton在程序1中都用到,能够正确编译,为何到了程序2中就不能正确编译?恳请高手赐教!